Repository: ciudadanointeligente/votainteligente-portal-electoral

Issue:
Banda candidato ganador
Banda o marca que permita destacar al candidato que ganó la elección.



Discussion:

Resolving patch:
diff --git a/elections/admin.py b/elections/admin.py
--- a/elections/admin.py
+++ b/elections/admin.py
@@ -39,7 +39,7 @@ class AnswerInline(admin.TabularInline):
 
 class CandidatePersonExtraInfoAdmin(admin.ModelAdmin):
     readonly_fields = ('person',)
-    fields = ('reachable','description', 'portrait_photo')
+    fields = ('reachable','description', 'portrait_photo', 'custom_ribbon')
     search_fields = ['person__name', 'person__api_instance__election__name']
 
 admin.site.register(CandidatePerson, CandidatePersonExtraInfoAdmin)
diff --git a/elections/migrations/0008_auto__add_field_candidateperson_custom_ribbon__chg_field_candidatepers.py b/elections/migrations/0008_auto__add_field_candidateperson_custom_ribbon__chg_field_candidatepers.py
new file mode 100644
--- /dev/null
+++ b/elections/migrations/0008_auto__add_field_candidateperson_custom_ribbon__chg_field_candidatepers.py
@@ -0,0 +1,186 @@
+# -*- coding: utf-8 -*-
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+
+class Migration(SchemaMigration):
+
+    def forwards(self, orm):
+        # Adding field 'CandidatePerson.custom_ribbon'
+        db.add_column(u'elections_candidateperson', 'custom_ribbon',
+                      self.gf('django.db.models.fields.CharField')(max_length=15, null=True, blank=True),
+                      keep_default=False)
+
+
+        # Changing field 'CandidatePerson.portrait_photo'
+        db.alter_column(u'elections_candidateperson', 'portrait_photo', self.gf('django.db.models.fields.CharField')(max_length=256, null=True))
+
+    def backwards(self, orm):
+        # Deleting field 'CandidatePerson.custom_ribbon'
+        db.delete_column(u'elections_candidateperson', 'custom_ribbon')
+
+
+        # Changing field 'CandidatePerson.portrait_photo'
+        db.alter_column(u'elections_candidateperson', 'portrait_photo', self.gf('django.db.models.fields.CharField')(default='', max_length=256))
+
+    models = {
+        u'candideitorg.answer': {
+            'Meta': {'object_name': 'Answer'},
+            'caption': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'question': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['candideitorg.Question']"}),
+            'remote_id': ('django.db.models.fields.IntegerField', [], {}),
+            'resource_uri': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+        },
+        u'candideitorg.candidate': {
+            'Meta': {'object_name': 'Candidate'},
+            'answers': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': u"orm['candideitorg.Answer']", 'null': 'True', 'blank': 'True'}),
+            'election': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['candideitorg.Election']"}),
+            'has_answered': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'photo': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
+            'remote_id': ('django.db.models.fields.IntegerField', [], {}),
+            'resource_uri': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'slug': ('django.db.models.fields.SlugField', [], {'max_length': '255'})
+        },
+        u'candideitorg.category': {
+            'Meta': {'object_name': 'Category'},
+            'election': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['candideitorg.Election']"}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'order': ('django.db.models.fields.IntegerField', [], {}),
+            'remote_id': ('django.db.models.fields.IntegerField', [], {}),
+            'resource_uri': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'slug': ('django.db.models.fields.SlugField', [], {'max_length': '255'})
+        },
+        u'candideitorg.election': {
+            'Meta': {'object_name': 'Election'},
+            'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'information_source': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+            'logo': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'remote_id': ('django.db.models.fields.IntegerField', [], {}),
+            'resource_uri': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'slug': ('django.db.models.fields.SlugField', [], {'max_length': '255'}),
+            'use_default_media_naranja_option': ('django.db.models.fields.BooleanField', [], {'default': 'False'})
+        },
+        u'candideitorg.question': {
+            'Meta': {'object_name': 'Question'},
+            'category': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['candideitorg.Category']"}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'question': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'remote_id': ('django.db.models.fields.IntegerField', [], {}),
+            'resource_uri': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+        },
+        u'contenttypes.contenttype': {
+            'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+            'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+        },
+        u'elections.candidateperson': {
+            'Meta': {'object_name': 'CandidatePerson'},
+            'candidate': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'relation'", 'unique': 'True', 'to': u"orm['candideitorg.Candidate']"}),
+            'custom_ribbon': ('django.db.models.fields.CharField', [], {'max_length': '15', 'null': 'True', 'blank': 'True'}),
+            'description': ('django.db.models.fields.TextField', [], {'default': "''", 'blank': 'True'}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'person': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'relation'", 'unique': 'True', 'to': u"orm['popit.Person']"}),
+            'portrait_photo': ('django.db.models.fields.CharField', [], {'max_length': '256', 'null': 'True', 'blank': 'True'}),
+            'reachable': ('django.db.models.fields.BooleanField', [], {'default': 'False'})
+        },
+        u'elections.election': {
+            'Meta': {'object_name': 'Election'},
+            'can_election': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['candideitorg.Election']", 'unique': 'True', 'null': 'True', 'blank': 'True'}),
+            'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+            'extra_info_content': ('django.db.models.fields.TextField', [], {'max_length': '3000', 'null': 'True', 'blank': 'True'}),
+            'extra_info_title': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}),
+            'highlighted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'popit_api_instance': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['popit.ApiInstance']", 'unique': 'True', 'null': 'True', 'blank': 'True'}),
+            'searchable': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'slug': ('autoslug.fields.AutoSlugField', [], {'unique': 'True', 'max_length': '50', 'populate_from': "'name'", 'unique_with': '()'}),
+            'uses_face_to_face': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'uses_preguntales': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'uses_questionary': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'uses_ranking': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'uses_soul_mate': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'writeitinstance': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['writeit.WriteItInstance']", 'unique': 'True', 'null': 'True', 'blank': 'True'})
+        },
+        u'elections.votainteligenteanswer': {
+            'Meta': {'object_name': 'VotaInteligenteAnswer'},
+            'content': ('django.db.models.fields.TextField', [], {}),
+            'created': ('django.db.models.fields.DateTimeField', [], {}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'message': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'answers'", 'to': u"orm['elections.VotaInteligenteMessage']"}),
+            'person': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'answers'", 'to': u"orm['popit.Person']"})
+        },
+        u'elections.votainteligentemessage': {
+            'Meta': {'object_name': 'VotaInteligenteMessage', '_ormbases': [u'writeit.Message']},
+            'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+            u'message_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['writeit.Message']", 'unique': 'True', 'primary_key': 'True'}),
+            'moderated': ('django.db.models.fields.BooleanField', [], {'default': 'False'})
+        },
+        u'popit.apiinstance': {
+            'Meta': {'object_name': 'ApiInstance'},
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'url': ('popit.fields.ApiInstanceURLField', [], {'unique': 'True', 'max_length': '200'})
+        },
+        u'popit.person': {
+            'Meta': {'object_name': 'Person'},
+            'api_instance': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['popit.ApiInstance']"}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'image': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
+            'popit_url': ('popit.fields.PopItURLField', [], {'default': "''", 'max_length': '200', 'unique': 'True', 'null': 'True', 'blank': 'True'}),
+            'summary': ('django.db.models.fields.TextField', [], {'blank': 'True'})
+        },
+        u'taggit.tag': {
+            'Meta': {'object_name': 'Tag'},
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}),
+            'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '100'})
+        },
+        u'taggit.taggeditem': {
+            'Meta': {'object_name': 'TaggedItem'},
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "u'taggit_taggeditem_tagged_items'", 'to': u"orm['contenttypes.ContentType']"}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'object_id': ('django.db.models.fields.IntegerField', [], {'db_index': 'True'}),
+            'tag': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "u'taggit_taggeditem_items'", 'to': u"orm['taggit.Tag']"})
+        },
+        u'writeit.message': {
+            'Meta': {'object_name': 'Message', '_ormbases': [u'writeit.WriteItDocument']},
+            'author_email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}),
+            'author_name': ('django.db.models.fields.CharField', [], {'max_length': '512'}),
+            'content': ('django.db.models.fields.TextField', [], {}),
+            'people': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'messages'", 'symmetrical': 'False', 'to': u"orm['popit.Person']"}),
+            'slug': ('django.db.models.fields.CharField', [], {'max_length': '512'}),
+            'subject': ('django.db.models.fields.CharField', [], {'max_length': '512'}),
+            u'writeitdocument_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['writeit.WriteItDocument']", 'unique': 'True', 'primary_key': 'True'}),
+            'writeitinstance': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['writeit.WriteItInstance']"})
+        },
+        u'writeit.writeitapiinstance': {
+            'Meta': {'object_name': 'WriteItApiInstance'},
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'url': ('django.db.models.fields.URLField', [], {'unique': 'True', 'max_length': '200'})
+        },
+        u'writeit.writeitdocument': {
+            'Meta': {'object_name': 'WriteItDocument'},
+            'api_instance': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['writeit.WriteItApiInstance']"}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'remote_id': ('django.db.models.fields.IntegerField', [], {'null': 'True'}),
+            'url': ('django.db.models.fields.CharField', [], {'max_length': '256'})
+        },
+        u'writeit.writeitinstance': {
+            'Meta': {'object_name': 'WriteItInstance', '_ormbases': [u'writeit.WriteItDocument']},
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            u'writeitdocument_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['writeit.WriteItDocument']", 'unique': 'True', 'primary_key': 'True'})
+        }
+    }
+
+    complete_apps = ['elections']
\ No newline at end of file
diff --git a/elections/models.py b/elections/models.py
--- a/elections/models.py
+++ b/elections/models.py
@@ -60,6 +60,7 @@ class CandidatePerson(models.Model):
     reachable = models.BooleanField(default=False)
     description = models.TextField(default='', blank=True)
     portrait_photo = models.CharField(max_length=256, blank=True, null=True)
+    custom_ribbon = models.CharField(max_length=15, blank=True, null=True)
 
     def __unicode__(self):
         return u'Extra info de %(candidate)s'%{


Test patch:
diff --git a/elections/tests/candideitorg_popit_tests.py b/elections/tests/candideitorg_popit_tests.py
--- a/elections/tests/candideitorg_popit_tests.py
+++ b/elections/tests/candideitorg_popit_tests.py
@@ -32,10 +32,25 @@ def test_create_a_model_that_relates_them_both(self):
             candidate=self.candidato1
             )
 
-        candidate_person.portrait_photo = 'http://imgur.com/0tJAgHo'
-        candidate_person.save()
+        self.assertEquals(candidate_person.person, self.pedro)
+        self.assertEquals(candidate_person.candidate, self.candidato1)
 
-        candidate_photo = CandidatePerson.objects.get(portrait_photo='http://imgur.com/0tJAgHo')
+        self.assertEquals(self.pedro.relation, candidate_person)
+        self.assertEquals(self.candidato1.relation, candidate_person)
+
+    def test_realtion_stores_extra_atributes(self):
+        candidate_person = CandidatePerson.objects.get(
+            person=self.pedro,
+            candidate=self.candidato1
+            )
+        #Deletes created relation
+        candidate_person.delete()
+        candidate_person = CandidatePerson.objects.create(
+            person=self.pedro,
+            candidate=self.candidato1,
+            portrait_photo ='http://imgur.com/0tJAgHo',
+            custom_ribbon = 'ribbon text'
+            )
 
         self.assertEquals(candidate_person.person, self.pedro)
         self.assertEquals(candidate_person.candidate, self.candidato1)
@@ -44,9 +59,10 @@ def test_create_a_model_that_relates_them_both(self):
         self.assertEquals(self.candidato1.relation, candidate_person)
         self.assertFalse(candidate_person.reachable)
         self.assertFalse(candidate_person.description)
-        self.assertEquals(candidate_photo.portrait_photo, 'http://imgur.com/0tJAgHo')
+        self.assertEquals(candidate_person.portrait_photo, 'http://imgur.com/0tJAgHo')
         # self.assertTrue(False)
 
+
     def test_it_creates_a_link_to_the_candidate_twitter(self):
         link = Link.objects.create(url = 'http://twitter.com/candidato1',\
             name = 'twitter',\