Skip to content

Commit

Permalink
Moving template tags and other things like adding a template tag for …
Browse files Browse the repository at this point in the history
…displaying the when parameter
  • Loading branch information
Felipe Álvarez committed Apr 13, 2016
1 parent bfc68f2 commit 7f93f14
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 5 deletions.
10 changes: 9 additions & 1 deletion popular_proposal/tests/form_tests.py
Expand Up @@ -10,7 +10,8 @@
from popular_proposal.models import ProposalTemporaryData
from django.core import mail
from django.template.loader import get_template
from django.template import Context
from django.template import Context, Template
from popular_proposal.forms import WHEN_CHOICES


class FormTestCase(TestCase):
Expand Down Expand Up @@ -167,3 +168,10 @@ def test_update_temporary_popular_proposal(self):
self.assertEquals(temporary_data.data, data)
self.assertEquals(temporary_data.status, ProposalTemporaryData.Statuses.InOurSide)

def test_when_template_tag(self):
choice = WHEN_CHOICES[0]
template = Template("{% load votainteligente_extras %}{{ '1_month'|popular_proposal_when }}")
self.assertEquals(template.render(Context({})), choice[1])
template = Template("{% load votainteligente_extras %}{{ 'perrito'|popular_proposal_when }}")
self.assertEquals(template.render(Context({})), 'perrito')

3 changes: 2 additions & 1 deletion votai_general_theme/templates/backend_citizen/index.html
@@ -1,5 +1,6 @@
{% extends "backend_base.html" %}
{% load staticfiles %}
{% load votainteligente_extras %}
{% load i18n %}
{% load thumbnail %}
{% load bootstrap_tags %}
Expand Down Expand Up @@ -34,7 +35,7 @@ <h1>{% blocktrans %}¡Bienvenid@ {{user}}!{% endblocktrans %}</h1>
<td>{{proposal.data.solution}}
{% include 'popular_proposal/_show_proposal_comments_to_user.html' with comments=proposal.comments.solution %}
</td>
<td>{{proposal.data.when}}
<td>{{proposal.data.when|popular_proposal_when}}
{% include 'popular_proposal/_show_proposal_comments_to_user.html' with comments=proposal.comments.when %}
</td>
<td>{{proposal.data.allies}}
Expand Down
3 changes: 2 additions & 1 deletion votai_general_theme/templates/backend_staff/index.html
@@ -1,5 +1,6 @@
{% extends "backend_base.html" %}
{% load staticfiles %}
{% load votainteligente_extras %}
{% load i18n %}
{% load thumbnail %}
{% load bootstrap_tags %}
Expand Down Expand Up @@ -34,7 +35,7 @@ <h2>{% blocktrans %}¡Eres parte de nuestro equipo!{% endblocktrans %}</h2>
</td>
<td>{{proposal.data.solution}}{% include 'popular_proposal/_show_proposal_comments.html' with comments=proposal.comments.solution %}
</td>
<td>{{proposal.data.when}}{% include 'popular_proposal/_show_proposal_comments.html' with comments=proposal.comments.when %}
<td>{{proposal.data.when|popular_proposal_when}}{% include 'popular_proposal/_show_proposal_comments.html' with comments=proposal.comments.when %}
</td>
<td>{{proposal.data.allies}}{% include 'popular_proposal/_show_proposal_comments.html' with comments=proposal.comments.allies %}
</td>
Expand Down
2 changes: 2 additions & 0 deletions votai_general_theme/templates/base.html
Expand Up @@ -82,6 +82,8 @@
<li><a href="{% url 'auth_logout' %}">{% blocktrans %}Salir{% endblocktrans %}</a></li>
</ul>
</li>
{% else %}
<li><a href="{% url 'auth_login' %}">{% blocktrans %}Ingresar{% endblocktrans %}</a></li>
{% endif %}
</ul>
</div><!--/.nav-collapse -->
Expand Down
@@ -1,11 +1,23 @@
{% load votainteligente_extras %}
¡Felicitaciones {{temporary_data.proposer}}!:
Tu propuesta para {{area}} fue aceptada por {{moderator}}.

Te queremos recordar que tu propuesta tiene la siguiente información.

{{temporary_data.created_proposal.data.problem}}
{{temporary_data.created_proposal.data.when}}
{{temporary_data.created_proposal.data.when|popular_proposal_when}}
{{temporary_data.created_proposal.data.solution}}


Puedes ver tu propuesta en el siguiente link:
http://2016.votainteligente.cl/{% url 'area' slug=area.id %}


Para hacer que tu propuesta llegue a ser parte de los programas
de los candidatos, te recomendamos que te organices con tus
vecinos y te hagas notar.


Muchas gracias.
--
Atentamente el equipo de VotaInteligente.cl
@@ -1,8 +1,9 @@
{% load votainteligente_extras %}
Hola {{temporary_data.proposer}}!
Hemos leido y moderado tu propuesta ciudadana y tenemos los siguientes comentarios:

{% for key, item in comments.items %}{% if item.comments %}
* Para tu respuesta: {{item.original}}, nuestros comentarios son:
* Para tu respuesta: {{item.original|popular_proposal_when}}, nuestros comentarios son:

{{ item.comments }}

Expand Down
File renamed without changes.
Expand Up @@ -9,6 +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


@register.simple_tag
Expand Down Expand Up @@ -173,8 +174,17 @@ def display_explanation(explanation, election):
'explanation_container': explanation
}


@register.filter(name='likes')
def likes(user, proposal):
if user in proposal.likers.all():
return True
return False


@register.filter(name='popular_proposal_when')
def popular_proposal_when(when):
for item in WHEN_CHOICES:
if item[0] == when:
return item[1]
return when

0 comments on commit 7f93f14

Please sign in to comment.