Mercurial > public > sg101
annotate gpp/templates/polls/poll.html @ 440:ac9217eef610
Added total vote information to the poll templates. Cache the total votes in the model instance.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 21 May 2011 20:35:02 +0000 |
parents | 1f139de929c4 |
children |
rev | line source |
---|---|
gremmie@1 | 1 {% extends 'base.html' %} |
bgneal@310 | 2 {% load url from future %} |
gremmie@1 | 3 {% load comment_tags %} |
gremmie@1 | 4 {% block title %}Polls: {{ poll.question }}{% endblock %} |
gremmie@1 | 5 {% block content %} |
gremmie@1 | 6 <h2>Poll</h2> |
gremmie@1 | 7 <h3>{{ poll.question }}</h3> |
gremmie@1 | 8 <ul class="poll-detail"> |
gremmie@1 | 9 {% for choice in poll.choice_set.all %} |
gremmie@1 | 10 <li>{{ choice.choice }}</li> |
gremmie@1 | 11 {% endfor %} |
gremmie@1 | 12 </ul> |
bgneal@439 | 13 {% if user_choice %} |
bgneal@439 | 14 <p>You voted for "{{ user_choice.choice }}".</p> |
bgneal@439 | 15 {% endif %} |
gremmie@1 | 16 {% get_comment_count for poll as comment_count %} |
gremmie@1 | 17 <p> |
bgneal@440 | 18 This poll has {{ poll.total_votes }} vote{{ poll.total_votes|pluralize }} and |
bgneal@440 | 19 <a href="{% url 'polls.views.poll_results' poll.id %}">{{ comment_count }} comment{{ comment_count|pluralize }}</a>. |
gremmie@1 | 20 {% if poll.is_open %} |
gremmie@1 | 21 Voting for this poll started on {{ poll.start_date|date:"F d, Y" }}. |
gremmie@1 | 22 {% if poll.end_date %} |
gremmie@1 | 23 Voting will end on {{ poll.end_date|date:"F d, Y" }}. |
gremmie@1 | 24 {% endif %} |
gremmie@1 | 25 {% else %} |
gremmie@1 | 26 This poll ran from {{ poll.start_date|date:"F d, Y" }} to {{ poll.end_date|date:"F d, Y" }}. |
gremmie@1 | 27 {% endif %} |
gremmie@1 | 28 </p> |
gremmie@1 | 29 <p class="poll-nav"> |
bgneal@439 | 30 <a href="{% url 'polls-results' poll.id %}">View Results & Comments</a> |
gremmie@1 | 31 {% if poll.is_open and user.is_authenticated %} |
bgneal@439 | 32 | <a href="{% url 'polls-vote' poll_id=poll.id %}">Vote</a> |
gremmie@1 | 33 {% endif %} |
bgneal@439 | 34 | <a href="{% url 'polls-main' %}">All Polls</a> |
gremmie@1 | 35 </p> |
gremmie@1 | 36 {% endblock %} |