Repository: ciudadanointeligente/votainteligente-portal-electoral

Issue:
Agregar un campo extra a las propuestas ciudadanas llamada algo así como ```featured``` y que sea un booleano.
Que las propuestas se ordenen con este campo primero y luego con lo que siga.


Discussion:

Resolving patch:
diff --git a/popular_proposal/migrations/0026_popularproposal_featured.py b/popular_proposal/migrations/0026_popularproposal_featured.py
new file mode 100644
--- /dev/null
+++ b/popular_proposal/migrations/0026_popularproposal_featured.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.7 on 2017-08-18 18:31
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('popular_proposal', '0025_popularproposal_content_type'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='popularproposal',
+            name='featured',
+            field=models.BooleanField(default=False),
+        ),
+    ]
diff --git a/popular_proposal/models.py b/popular_proposal/models.py
--- a/popular_proposal/models.py
+++ b/popular_proposal/models.py
@@ -211,6 +211,7 @@ class PopularProposal(models.Model, OGPMixin):
     is_reported = models.BooleanField(default=False)
 
     content_type = models.ForeignKey(ContentType, null=True)
+    featured = models.BooleanField(default=False)
 
     ogp_enabled = True
 
@@ -219,7 +220,7 @@ class PopularProposal(models.Model, OGPMixin):
     all_objects = models.Manager()
 
     class Meta:
-        ordering = ['for_all_areas', '-created']
+        ordering = ['-featured' ,'for_all_areas', '-created']
         verbose_name = _(u'Propuesta Ciudadana')
         verbose_name_plural = _(u'Propuestas Ciudadanas')
 


Test patch:
diff --git a/popular_proposal/tests/popular_proposal_model_tests.py b/popular_proposal/tests/popular_proposal_model_tests.py
--- a/popular_proposal/tests/popular_proposal_model_tests.py
+++ b/popular_proposal/tests/popular_proposal_model_tests.py
@@ -42,6 +42,7 @@ def test_instantiate_one(self):
         self.assertFalse(popular_proposal.for_all_areas)
         self.assertFalse(popular_proposal.is_local_meeting)
         self.assertFalse(popular_proposal.is_reported)
+        self.assertFalse(popular_proposal.featured)
         content_type = popular_proposal.content_type
         expected_content_type = ContentType.objects.get_for_model(PopularProposal)
         self.assertEquals(content_type, expected_content_type)
@@ -82,6 +83,29 @@ def test_reportedproposals_are_not_in_default_manager(self):
         self.assertIn(p1, PopularProposal.all_objects.all())
         self.assertIn(p2, PopularProposal.all_objects.all())
 
+    def test_featured_proposals_are_first(self):
+        p1 = PopularProposal.objects.create(proposer=self.fiera,
+                                            area=self.arica,
+                                            data=self.data,
+                                            title=u'This is a title1',
+                                            clasification=u'education'
+                                            )
+        p2 = PopularProposal.objects.create(proposer=self.fiera,
+                                            area=self.arica,
+                                            data=self.data,
+                                            title=u'This is a title2',
+                                            clasification=u'education',
+                                            featured=True
+                                            )
+        p3 = PopularProposal.objects.create(proposer=self.fiera,
+                                            area=self.arica,
+                                            data=self.data,
+                                            title=u'This is a title3',
+                                            clasification=u'education'
+                                            )
+        proposals = PopularProposal.objects.all()
+        self.assertEquals(p2, proposals.first())
+
     def test_proposal_ogp(self):
         site = Site.objects.get_current()
         popular_proposal = PopularProposal.objects.create(proposer=self.fiera,