Repository: ciudadanointeligente/votainteligente-portal-electoral

Issue:
Los presidents_features es un campo de tags



Discussion:

Resolving patch:
diff --git a/votita/forms/forms.py b/votita/forms/forms.py
--- a/votita/forms/forms.py
+++ b/votita/forms/forms.py
@@ -29,10 +29,11 @@ def __init__(self, *args, **kwargs):
         self.proposer = kwargs.pop('proposer')
         super(CreateGatheringForm, self).__init__(*args, **kwargs)
 
-    def save(self):
+    def save(self, commit=True):
         instance = super(CreateGatheringForm, self).save(commit=False)
         instance.proposer = self.proposer
         instance.save()
+        self.save_m2m()
         return instance
 
 
diff --git a/votita/migrations/0003_auto_20170811_1542.py b/votita/migrations/0003_auto_20170811_1542.py
new file mode 100644
--- /dev/null
+++ b/votita/migrations/0003_auto_20170811_1542.py
@@ -0,0 +1,26 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.7 on 2017-08-11 15:42
+from __future__ import unicode_literals
+
+from django.db import migrations
+import taggit.managers
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('taggit', '0002_auto_20150616_2121'),
+        ('votita', '0002_kidsgathering_generated_at'),
+    ]
+
+    operations = [
+        migrations.RemoveField(
+            model_name='kidsgathering',
+            name='presidents_features',
+        ),
+        migrations.AddField(
+            model_name='kidsgathering',
+            name='presidents_features',
+            field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Caracter\xedsticas de un buen presidente'),
+        ),
+    ]
diff --git a/votita/models.py b/votita/models.py
--- a/votita/models.py
+++ b/votita/models.py
@@ -7,6 +7,7 @@
 from multiselectfield import MultiSelectField
 from django.contrib.auth.models import User
 from elections.models import Area
+from taggit.managers import TaggableManager
 
 
 PRESIDENTS_FEATURES = (
@@ -54,11 +55,7 @@ class KidsGathering(models.Model):
     name = models.CharField(max_length=512,
                             verbose_name="Nombre del encuentro")
     stats_data = PickledObjectField()
-    presidents_features = MultiSelectField(choices=PRESIDENTS_FEATURES,
-                                           null=True,
-                                           max_choices=10,
-                                           max_length=512,
-                                           verbose_name="Características de un buen presidente")
+    presidents_features = TaggableManager(verbose_name="Características de un buen presidente")
     created = models.DateTimeField(auto_now_add=True)
     updated = models.DateTimeField(auto_now_add=True)
     image = models.ImageField(upload_to='votita/images/',


Test patch:
diff --git a/votita/tests/forms_tests.py b/votita/tests/forms_tests.py
--- a/votita/tests/forms_tests.py
+++ b/votita/tests/forms_tests.py
@@ -27,13 +27,13 @@ def setUp(self):
 
     def test_create_a_gathering(self):
         data = {"name": "Segundo medio C",
-                "presidents_features": ["inteligente"],
+                "presidents_features": "inteligente,honesto",
                 "generated_at": self.a_comuna.id}
         form = CreateGatheringForm(data, proposer=self.feli)
         self.assertTrue(form.is_valid())
         gathering = form.save()
         self.assertEquals(gathering.name, data['name'])
-        self.assertTrue(gathering.presidents_features)
+        self.assertTrue(gathering.presidents_features.all())
         self.assertEquals(gathering.generated_at, self.a_comuna)
 
     def test_update_gathering(self):