From d589517a84b39b1cb8415a3c66b6cfe899c25b5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Felipe=20=C3=81lvarez=20Burgos?= Date: Mon, 18 Apr 2016 18:31:20 -0300 Subject: [PATCH 1/7] =?UTF-8?q?Cantidad=20de=20l=C3=ADneas=20en=20la=20des?= =?UTF-8?q?cripci=C3=B3n=20del=20problema?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #333 --- popular_proposal/forms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/popular_proposal/forms.py b/popular_proposal/forms.py index be3a3880..e5c5f901 100644 --- a/popular_proposal/forms.py +++ b/popular_proposal/forms.py @@ -54,7 +54,7 @@ class ProposalFormBase(forms.Form): problem = forms.CharField(label=_(u'Según la óptica de tu organización, describe un problema de tu comuna que \ - quieras solucionar. líneas)'), + quieras solucionar. 2 líneas)'), help_text=_(u'Ej: Poca participación en el Plan Regulador, falta de transparencia en el trabajo de la \ municipalidad, pocos puntos de reciclaje, etc.')) solution = forms.CharField(label=_(u'¿Qué debería hacer la municipalidad para solucionar el problema? (3 líneas)'), From a63b1f7e34b5a9e0222daa7d645ea2056db8bba8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Felipe=20=C3=81lvarez=20Burgos?= Date: Mon, 18 Apr 2016 22:18:19 +0000 Subject: [PATCH 2/7] Adding 512 as maxlength for the form in problem and 216 for solution and allies --- popular_proposal/forms.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/popular_proposal/forms.py b/popular_proposal/forms.py index e5c5f901..89f47228 100644 --- a/popular_proposal/forms.py +++ b/popular_proposal/forms.py @@ -55,18 +55,25 @@ class ProposalFormBase(forms.Form): problem = forms.CharField(label=_(u'Según la óptica de tu organización, describe un problema de tu comuna que \ quieras solucionar. 2 líneas)'), - help_text=_(u'Ej: Poca participación en el Plan Regulador, falta de transparencia en el trabajo de la \ - municipalidad, pocos puntos de reciclaje, etc.')) + help_text=_(u'Ej: Poca participación en el Plan Regulador, falta de transparencia en \ + el trabajo de la municipalidad, pocos puntos de reciclaje, etc.'), + max_length=512) solution = forms.CharField(label=_(u'¿Qué debería hacer la municipalidad para solucionar el problema? (3 líneas)'), - help_text=_(u'Ejemplo: "Crear una ciclovia que circunvale Valdivia", "Que se publiquen todos los concejos municipales en \ - el sitio web del municipio".')) + help_text=_(u'Ejemplo: "Crear una ciclovia que circunvale Valdivia", \ + "Que se publiquen todos los concejos municipales en el sitio web del municipio".'), + max_length=256, + ) solution_at_the_end = forms.CharField(label=u"¿Qué avances concretos esperas que se logren durante el periodo del alcalde (4 años)?", - help_text=_(u'Ejemplo: "Aumentar en un 20% la cantidad de ciclovías en la ciudad"'), required=False) + help_text=_(u'Ejemplo: "Aumentar en un 20% la cantidad de ciclovías en la ciudad"'), + required=False) when = forms.ChoiceField(choices=WHEN_CHOICES, label=_(u'¿En qué plazo te gustaría que esté solucionado?')) - title = forms.CharField(label=_(u'Título corto'), help_text=_(u"Un título que nos permita describir tu propuesta\ - ciudadana. Ej: 50% más de ciclovías para la comuna")) + title = forms.CharField(label=_(u'Título corto'), + help_text=_(u"Un título que nos permita describir tu propuesta\ + ciudadana. Ej: 50% más de ciclovías para la comuna"), + max_length=256,) clasification = forms.ChoiceField(choices=TOPIC_CHOICES, label=_(u'¿Cómo clasificarías tu propuesta?')) - allies = forms.CharField(label=_(u'¿Quiénes son tus posibles aliados?')) + allies = forms.CharField(label=_(u'¿Quiénes son tus posibles aliados?'), + max_length=256) organization = forms.CharField(label=_(u'¿Estás haciendo esta propuesta a nombre de una organización? Escribe su nombre acá:'), required=False) From ee3eb769a0a586e7579c0d0eaca188c2e974e99e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Felipe=20=C3=81lvarez=20Burgos?= Date: Mon, 18 Apr 2016 20:58:10 +0000 Subject: [PATCH 3/7] Adding new slug field for popular_proposal --- backend_citizen/urls.py | 2 +- backend_staff/urls.py | 2 +- elections/models.py | 2 +- elections/urls.py | 2 +- .../migrations/0009_popularproposal_slug.py | 21 +++++++++++++++++++ popular_proposal/models.py | 2 ++ .../tests/new_proposal_cycle_tests.py | 1 + popular_proposal/tests/views_tests.py | 10 +++++++++ popular_proposal/urls.py | 2 +- votainteligente/votainteligente_settings.py | 1 - 10 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 popular_proposal/migrations/0009_popularproposal_slug.py diff --git a/backend_citizen/urls.py b/backend_citizen/urls.py index e508d47e..88012cef 100644 --- a/backend_citizen/urls.py +++ b/backend_citizen/urls.py @@ -5,7 +5,7 @@ ) urlpatterns = patterns('', - url(r'^index/?$', + url(r'^$', IndexView.as_view(), name='index'), url(r'^update_temporary_data/(?P[\d]+)/?$', diff --git a/backend_staff/urls.py b/backend_staff/urls.py index 81486923..a4d7fa2e 100644 --- a/backend_staff/urls.py +++ b/backend_staff/urls.py @@ -9,7 +9,7 @@ ) urlpatterns = patterns('', - url(r'^index/?$', + url(r'^$', IndexView.as_view(), name='index'), url(r'^popular_proposal_comments/(?P[-\w]+)/?$', diff --git a/elections/models.py b/elections/models.py index c234eed9..b9f7f2e2 100644 --- a/elections/models.py +++ b/elections/models.py @@ -30,7 +30,7 @@ def __init__(self, *args, **kwargs): class Candidate(Person, ExtraInfoMixin): - elections = models.ManyToManyField('Election', related_name='candidates', null=True, default=None) + elections = models.ManyToManyField('Election', related_name='candidates', default=None) force_has_answer = models.BooleanField(default=False, help_text=_('Marca esto si quieres que el candidato aparezca como que no ha respondido')) diff --git a/elections/urls.py b/elections/urls.py index ea37e607..c67df559 100644 --- a/elections/urls.py +++ b/elections/urls.py @@ -25,7 +25,7 @@ } urlpatterns = patterns('', - url(r'^/?$', cache_page(60 * settings.CACHE_MINUTES)(HomeView.as_view(template_name='elections/home.html')), name='home'), + url(r'^$', cache_page(60 * settings.CACHE_MINUTES)(HomeView.as_view(template_name='elections/home.html')), name='home'), url(r'^buscar/?$', SearchView(template='search.html', form_class=ElectionForm), name='search'), url(r'^busqueda_tags/?$', ElectionsSearchByTagView.as_view(), name='tags_search'), diff --git a/popular_proposal/migrations/0009_popularproposal_slug.py b/popular_proposal/migrations/0009_popularproposal_slug.py new file mode 100644 index 00000000..f846d9fe --- /dev/null +++ b/popular_proposal/migrations/0009_popularproposal_slug.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.2 on 2016-04-18 20:56 +from __future__ import unicode_literals + +import autoslug.fields +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('popular_proposal', '0008_proposaltemporarydata_overall_comments'), + ] + + operations = [ + migrations.AddField( + model_name='popularproposal', + name='slug', + field=autoslug.fields.AutoSlugField(default='', editable=False, populate_from='title', unique=True), + ), + ] diff --git a/popular_proposal/models.py b/popular_proposal/models.py index cac1a483..d0cb9940 100644 --- a/popular_proposal/models.py +++ b/popular_proposal/models.py @@ -9,6 +9,7 @@ from django.utils.encoding import python_2_unicode_compatible from backend_citizen.models import Enrollment from django.contrib.sites.models import Site +from autoslug import AutoSlugField class NeedingModerationManager(models.Manager): @@ -105,6 +106,7 @@ def __str__(self): @python_2_unicode_compatible class PopularProposal(models.Model): title = models.CharField(max_length=255, default='') + slug = AutoSlugField(populate_from='title', unique=True, default='') proposer = models.ForeignKey(User, related_name='proposals') area = models.ForeignKey(Area, related_name='proposals') data = PickledObjectField() diff --git a/popular_proposal/tests/new_proposal_cycle_tests.py b/popular_proposal/tests/new_proposal_cycle_tests.py index a03b9500..b90c774d 100644 --- a/popular_proposal/tests/new_proposal_cycle_tests.py +++ b/popular_proposal/tests/new_proposal_cycle_tests.py @@ -126,6 +126,7 @@ def test_instantiate_one(self): ) self.assertTrue(popular_proposal.created) self.assertTrue(popular_proposal.updated) + self.assertTrue(popular_proposal.slug) self.assertEquals(popular_proposal.title, u'This is a title') self.assertIn(popular_proposal, self.fiera.proposals.all()) self.assertIn(popular_proposal, self.arica.proposals.all()) diff --git a/popular_proposal/tests/views_tests.py b/popular_proposal/tests/views_tests.py index 9894aad5..dc402107 100644 --- a/popular_proposal/tests/views_tests.py +++ b/popular_proposal/tests/views_tests.py @@ -1,6 +1,7 @@ # coding=utf-8 from popular_proposal.tests import ProposingCycleTestCaseBase as TestCase from django.core.urlresolvers import reverse +from popular_proposal.models import PopularProposal class ProposalViewTestCase(TestCase): @@ -12,3 +13,12 @@ def test_there_is_a_page(self): response = self.client.get(url) self.assertEquals(response.status_code, 200) self.assertTemplateUsed('popular_proposals/home.html') + + # def test_there_is_a_page_for_popular_proposal(self): + # popular_proposal = PopularProposal.objects.create(proposer=self.fiera, + # area=self.arica, + # data=self.data, + # title=u'This is a title' + # ) + # # no need to be logged in + # url = reverse('popular_proposals:detail', kwargs={''}) \ No newline at end of file diff --git a/popular_proposal/urls.py b/popular_proposal/urls.py index 74662541..9e86d5cf 100644 --- a/popular_proposal/urls.py +++ b/popular_proposal/urls.py @@ -6,7 +6,7 @@ ) urlpatterns = patterns('', - url(r'^/?$', + url(r'^$', HomeView.as_view(), name='home'), url(r'^(?P[-\w]+)/?$', diff --git a/votainteligente/votainteligente_settings.py b/votainteligente/votainteligente_settings.py index d50c1cec..0ed6331b 100644 --- a/votainteligente/votainteligente_settings.py +++ b/votainteligente/votainteligente_settings.py @@ -6,7 +6,6 @@ DEBUG = True -TEMPLATE_DEBUG = DEBUG DEFAULT_CANDIDATE_EXTRA_INFO = { "portrait_photo": "/static/img/candidate-default.jpg", 'custom_ribbon': 'ribbon text' From 7b08385a3dd88608c5bc5dc36923276372f743e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Felipe=20=C3=81lvarez=20Burgos?= Date: Mon, 18 Apr 2016 22:05:12 +0000 Subject: [PATCH 4/7] A proposal has its own page --- .../migrations/0010_auto_20160418_2117.py | 24 +++++++++++ popular_proposal/models.py | 3 +- popular_proposal/tests/views_tests.py | 20 +++++---- popular_proposal/urls.py | 4 ++ popular_proposal/views.py | 7 +++ .../templates/popular_proposal/_likers.html | 36 ++++++++++++++++ .../templates/popular_proposal/detail.html | 43 +++++++++++++++++++ .../popular_proposal_card.html | 35 ++------------- 8 files changed, 131 insertions(+), 41 deletions(-) create mode 100644 popular_proposal/migrations/0010_auto_20160418_2117.py create mode 100644 votai_general_theme/templates/popular_proposal/_likers.html create mode 100644 votai_general_theme/templates/popular_proposal/detail.html diff --git a/popular_proposal/migrations/0010_auto_20160418_2117.py b/popular_proposal/migrations/0010_auto_20160418_2117.py new file mode 100644 index 00000000..35b57a2d --- /dev/null +++ b/popular_proposal/migrations/0010_auto_20160418_2117.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.2 on 2016-04-18 21:17 +from __future__ import unicode_literals + +from django.db import migrations + + +def gen_slug(apps, schema_editor): + PopularProposal = apps.get_model('popular_proposal', 'PopularProposal') + counter = 0 + for popular_proposal in PopularProposal.objects.all(): + counter += 1 + popular_proposal.slug = 'proposal_{:d}'.format(counter) + popular_proposal.save() + +class Migration(migrations.Migration): + + dependencies = [ + ('popular_proposal', '0009_popularproposal_slug'), + ] + + operations = [ + migrations.RunPython(gen_slug, reverse_code=migrations.RunPython.noop), + ] diff --git a/popular_proposal/models.py b/popular_proposal/models.py index d0cb9940..2784d66a 100644 --- a/popular_proposal/models.py +++ b/popular_proposal/models.py @@ -10,6 +10,7 @@ from backend_citizen.models import Enrollment from django.contrib.sites.models import Site from autoslug import AutoSlugField +import uuid class NeedingModerationManager(models.Manager): @@ -106,7 +107,7 @@ def __str__(self): @python_2_unicode_compatible class PopularProposal(models.Model): title = models.CharField(max_length=255, default='') - slug = AutoSlugField(populate_from='title', unique=True, default='') + slug = AutoSlugField(populate_from='title', unique=True, default=uuid.uuid4) proposer = models.ForeignKey(User, related_name='proposals') area = models.ForeignKey(Area, related_name='proposals') data = PickledObjectField() diff --git a/popular_proposal/tests/views_tests.py b/popular_proposal/tests/views_tests.py index dc402107..dfb8bdc4 100644 --- a/popular_proposal/tests/views_tests.py +++ b/popular_proposal/tests/views_tests.py @@ -14,11 +14,15 @@ def test_there_is_a_page(self): self.assertEquals(response.status_code, 200) self.assertTemplateUsed('popular_proposals/home.html') - # def test_there_is_a_page_for_popular_proposal(self): - # popular_proposal = PopularProposal.objects.create(proposer=self.fiera, - # area=self.arica, - # data=self.data, - # title=u'This is a title' - # ) - # # no need to be logged in - # url = reverse('popular_proposals:detail', kwargs={''}) \ No newline at end of file + def test_there_is_a_page_for_popular_proposal(self): + popular_proposal = PopularProposal.objects.create(proposer=self.fiera, + area=self.arica, + data=self.data, + title=u'This is a title' + ) + # no need to be logged in + url = reverse('popular_proposals:detail', kwargs={'slug': popular_proposal.slug}) + response = self.client.get(url) + self.assertEquals(response.status_code, 200) + self.assertEqual(response.context['popular_proposal'], popular_proposal) + self.assertTemplateUsed(response, 'popular_proposal/detail.html') \ No newline at end of file diff --git a/popular_proposal/urls.py b/popular_proposal/urls.py index 9e86d5cf..98014be8 100644 --- a/popular_proposal/urls.py +++ b/popular_proposal/urls.py @@ -3,12 +3,16 @@ ThanksForProposingView, SubscriptionView, HomeView, + PopularProposalDetailView, ) urlpatterns = patterns('', url(r'^$', HomeView.as_view(), name='home'), + url(r'^detail/(?P[-\w]+)/?$', + PopularProposalDetailView.as_view(), + name='detail'), url(r'^(?P[-\w]+)/?$', ProposalCreationView.as_view(), name='propose'), diff --git a/popular_proposal/views.py b/popular_proposal/views.py index 66545895..7f889662 100644 --- a/popular_proposal/views.py +++ b/popular_proposal/views.py @@ -6,6 +6,7 @@ from django.utils.decorators import method_decorator from django.contrib.auth.decorators import login_required from django.views.generic.base import TemplateView +from django.views.generic.detail import DetailView from popular_proposal.models import PopularProposal @@ -71,3 +72,9 @@ def form_valid(self, form): class HomeView(TemplateView): template_name = 'popular_proposal/home.html' + + +class PopularProposalDetailView(DetailView): + model = PopularProposal + template_name = 'popular_proposal/detail.html' + context_object_name = 'popular_proposal' \ No newline at end of file diff --git a/votai_general_theme/templates/popular_proposal/_likers.html b/votai_general_theme/templates/popular_proposal/_likers.html new file mode 100644 index 00000000..502757ec --- /dev/null +++ b/votai_general_theme/templates/popular_proposal/_likers.html @@ -0,0 +1,36 @@ +{% load staticfiles %} +{% load votainteligente_extras %} +{% load i18n %} +{% load thumbnail %} +{% if proposal.likers.all %} + +
+
+ + +
+
+{% endif %} +
+
+ {% if user.is_authenticated %} + + {% if not user|likes:proposal %} + + {% blocktrans %}Apoyar{% endblocktrans %} + + + {% endif %} + {% else %} + + {% blocktrans %}Apoyar{% endblocktrans %} + + + + {% endif%} +
+
\ No newline at end of file diff --git a/votai_general_theme/templates/popular_proposal/detail.html b/votai_general_theme/templates/popular_proposal/detail.html new file mode 100644 index 00000000..84e91d40 --- /dev/null +++ b/votai_general_theme/templates/popular_proposal/detail.html @@ -0,0 +1,43 @@ +{% extends "base.html" %} +{% load votainteligente_extras %} +{% load staticfiles %} +{% load i18n %} +{% load thumbnail %} +{% load bootstrap_tags %} +{% block extrajs %} +$(function(){ + $('.loadFromUrl').on('show.bs.modal', function (event) { + var anchor = $(event.relatedTarget) // Button that triggered the modal + var modal = $(this) + var body = modal.find('.modal-body'); + body.load(anchor.data('url')); + }) + $('[data-toggle="tooltip"]').tooltip(); +}); +{% endblock extrajs %} + +{% block content %} +{% include 'modal.html' with modalId='supportProposal' title='Apoya una propuesta' %} +
+ + + +
+

{{popular_proposal.title}}

+ + +
+ + + {% for key, value in popular_proposal.data.items %} +
{{key}}
+
{{value|popular_proposal_when}}
+ {% endfor %} +
+
+ {% include 'popular_proposal/_likers.html' with proposal=popular_proposal %} +
+{% endblock content %} + +{% block extrafooter %} +{% endblock extrafooter %} \ No newline at end of file diff --git a/votai_general_theme/templates/popular_proposal/popular_proposal_card.html b/votai_general_theme/templates/popular_proposal/popular_proposal_card.html index af20f615..4e377c36 100644 --- a/votai_general_theme/templates/popular_proposal/popular_proposal_card.html +++ b/votai_general_theme/templates/popular_proposal/popular_proposal_card.html @@ -10,37 +10,8 @@ {% else %} {{proposal.data.solution}} {% endif %} - {% if proposal.likers.all %} -
-
- - -
-
- {% endif %} -
-
- {% if user.is_authenticated %} - - {% if not user|likes:proposal %} - - {% blocktrans %}Apoyar{% endblocktrans %} - - - {% endif %} - {% else %} - - {% blocktrans %}Apoyar{% endblocktrans %} - - - - {% endif%} -
-
- + + {% include 'popular_proposal/_likers.html' with proposal=proposal %} + From 688c6eb180da26c2a963ce1b1bf218805a67a41e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Felipe=20=C3=81lvarez=20Burgos?= Date: Mon, 18 Apr 2016 22:42:57 +0000 Subject: [PATCH 5/7] Displaying the quiestions from the form in the detail part of the proposal --- popular_proposal/forms.py | 8 ++++---- popular_proposal/tests/form_tests.py | 10 +++++++++- .../templates/popular_proposal/detail.html | 2 +- .../templatetags/votainteligente_extras.py | 9 ++++++++- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/popular_proposal/forms.py b/popular_proposal/forms.py index 89f47228..c870c39f 100644 --- a/popular_proposal/forms.py +++ b/popular_proposal/forms.py @@ -54,13 +54,13 @@ class ProposalFormBase(forms.Form): problem = forms.CharField(label=_(u'Según la óptica de tu organización, describe un problema de tu comuna que \ - quieras solucionar. 2 líneas)'), +quieras solucionar. (2 líneas)'), help_text=_(u'Ej: Poca participación en el Plan Regulador, falta de transparencia en \ - el trabajo de la municipalidad, pocos puntos de reciclaje, etc.'), +el trabajo de la municipalidad, pocos puntos de reciclaje, etc.'), max_length=512) solution = forms.CharField(label=_(u'¿Qué debería hacer la municipalidad para solucionar el problema? (3 líneas)'), help_text=_(u'Ejemplo: "Crear una ciclovia que circunvale Valdivia", \ - "Que se publiquen todos los concejos municipales en el sitio web del municipio".'), +"Que se publiquen todos los concejos municipales en el sitio web del municipio".'), max_length=256, ) solution_at_the_end = forms.CharField(label=u"¿Qué avances concretos esperas que se logren durante el periodo del alcalde (4 años)?", @@ -69,7 +69,7 @@ class ProposalFormBase(forms.Form): when = forms.ChoiceField(choices=WHEN_CHOICES, label=_(u'¿En qué plazo te gustaría que esté solucionado?')) title = forms.CharField(label=_(u'Título corto'), help_text=_(u"Un título que nos permita describir tu propuesta\ - ciudadana. Ej: 50% más de ciclovías para la comuna"), +ciudadana. Ej: 50% más de ciclovías para la comuna"), max_length=256,) clasification = forms.ChoiceField(choices=TOPIC_CHOICES, label=_(u'¿Cómo clasificarías tu propuesta?')) allies = forms.CharField(label=_(u'¿Quiénes son tus posibles aliados?'), diff --git a/popular_proposal/tests/form_tests.py b/popular_proposal/tests/form_tests.py index a0d40617..f37bb365 100644 --- a/popular_proposal/tests/form_tests.py +++ b/popular_proposal/tests/form_tests.py @@ -12,7 +12,7 @@ from django.core import mail from django.template.loader import get_template from django.template import Context, Template -from popular_proposal.forms import WHEN_CHOICES +from popular_proposal.forms import WHEN_CHOICES, ProposalFormBase class FormTestCase(ProposingCycleTestCaseBase): @@ -161,3 +161,11 @@ def test_when_template_tag(self): template = Template("{% load votainteligente_extras %}{{ 'perrito'|popular_proposal_when }}") self.assertEquals(template.render(Context({})), 'perrito') + def test_form_questions_template_tag(self): + fields = ProposalFormBase.base_fields + key = fields.keys()[0] + question = fields[key].label + template = Template("{% load votainteligente_extras %}{{ 'problem'|popular_proposal_question }}") + self.assertEquals(template.render(Context({})), question) + template = Template("{% load votainteligente_extras %}{{ 'perrito'|popular_proposal_question }}") + self.assertEquals(template.render(Context({})), 'perrito') \ No newline at end of file diff --git a/votai_general_theme/templates/popular_proposal/detail.html b/votai_general_theme/templates/popular_proposal/detail.html index 84e91d40..a81c934f 100644 --- a/votai_general_theme/templates/popular_proposal/detail.html +++ b/votai_general_theme/templates/popular_proposal/detail.html @@ -30,7 +30,7 @@

{{popular_proposal.title}}

{% for key, value in popular_proposal.data.items %} -
{{key}}
+
{{key|popular_proposal_question}}
{{value|popular_proposal_when}}
{% endfor %} diff --git a/votai_general_theme/templatetags/votainteligente_extras.py b/votai_general_theme/templatetags/votainteligente_extras.py index 3d2f79ab..979900f6 100644 --- a/votai_general_theme/templatetags/votainteligente_extras.py +++ b/votai_general_theme/templatetags/votainteligente_extras.py @@ -9,7 +9,7 @@ from django.contrib.sites.models import Site from popolo.models import Area from django.core.urlresolvers import reverse -from popular_proposal.forms import WHEN_CHOICES +from popular_proposal.forms import WHEN_CHOICES, ProposalFormBase @register.simple_tag @@ -188,3 +188,10 @@ def popular_proposal_when(when): if item[0] == when: return item[1] return when + +@register.filter(name='popular_proposal_question') +def popular_proposal_question(question): + fields = ProposalFormBase.base_fields + if question not in fields.keys(): + return question + return getattr(fields[question], 'label', question) \ No newline at end of file From 75c96eb23d19e90539c8a21b152ab91d60dfe95b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Felipe=20=C3=81lvarez=20Burgos?= Date: Mon, 18 Apr 2016 23:06:07 +0000 Subject: [PATCH 6/7] Removing uuid as the default value for slugs --- popular_proposal/models.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/popular_proposal/models.py b/popular_proposal/models.py index 2784d66a..cd1be1a1 100644 --- a/popular_proposal/models.py +++ b/popular_proposal/models.py @@ -10,7 +10,7 @@ from backend_citizen.models import Enrollment from django.contrib.sites.models import Site from autoslug import AutoSlugField -import uuid +from django.core.urlresolvers import reverse class NeedingModerationManager(models.Manager): @@ -107,7 +107,7 @@ def __str__(self): @python_2_unicode_compatible class PopularProposal(models.Model): title = models.CharField(max_length=255, default='') - slug = AutoSlugField(populate_from='title', unique=True, default=uuid.uuid4) + slug = AutoSlugField(populate_from='title', unique=True) proposer = models.ForeignKey(User, related_name='proposals') area = models.ForeignKey(Area, related_name='proposals') data = PickledObjectField() @@ -122,6 +122,9 @@ class PopularProposal(models.Model): def __str__(self): return self.title + + def get_absolute_url(self): + return reverse('popular_proposals:detail', kwargs={'slug': self.slug}) class Subscription(models.Model): From 205131500f6ae2ed4160e5d18069506a633eb462 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Felipe=20=C3=81lvarez=20Burgos?= Date: Mon, 18 Apr 2016 23:06:44 +0000 Subject: [PATCH 7/7] Sending the url of the proposal in the email --- popular_proposal/tests/views_tests.py | 1 + .../templates/mails/popular_proposal_accepted_body.html | 3 +++ votai_general_theme/templates/popular_proposal/detail.html | 4 +++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/popular_proposal/tests/views_tests.py b/popular_proposal/tests/views_tests.py index dfb8bdc4..85fa1e2d 100644 --- a/popular_proposal/tests/views_tests.py +++ b/popular_proposal/tests/views_tests.py @@ -22,6 +22,7 @@ def test_there_is_a_page_for_popular_proposal(self): ) # no need to be logged in url = reverse('popular_proposals:detail', kwargs={'slug': popular_proposal.slug}) + self.assertEquals(popular_proposal.get_absolute_url(), url) response = self.client.get(url) self.assertEquals(response.status_code, 200) self.assertEqual(response.context['popular_proposal'], popular_proposal) diff --git a/votai_general_theme/templates/mails/popular_proposal_accepted_body.html b/votai_general_theme/templates/mails/popular_proposal_accepted_body.html index 11743a93..53bafcd7 100644 --- a/votai_general_theme/templates/mails/popular_proposal_accepted_body.html +++ b/votai_general_theme/templates/mails/popular_proposal_accepted_body.html @@ -10,6 +10,9 @@ Puedes ver tu propuesta en el siguiente link: +http://{{site.domain}}{{ temporary_data.created_proposal.get_absolute_url }} + +Y acá puedes ver la lista de todas las propuestas de {{area}}: http://{{site.domain}}{% url 'area' slug=area.id %} diff --git a/votai_general_theme/templates/popular_proposal/detail.html b/votai_general_theme/templates/popular_proposal/detail.html index a81c934f..d339b1b9 100644 --- a/votai_general_theme/templates/popular_proposal/detail.html +++ b/votai_general_theme/templates/popular_proposal/detail.html @@ -16,6 +16,8 @@ }); {% endblock extrajs %} +{% block title %}{{popular_proposal.title}}{% endblock title%} + {% block content %} {% include 'modal.html' with modalId='supportProposal' title='Apoya una propuesta' %}
@@ -26,7 +28,7 @@

{{popular_proposal.title}}

-
+
{% for key, value in popular_proposal.data.items %}