comparison gpp/templates/polls/poll_detail.html @ 447:8f46ba2f1b81

For #219, rework the polls views for a better flow. Added some tests for the views.
author Brian Neal <bgneal@gmail.com>
date Sat, 25 Jun 2011 23:23:20 +0000
parents
children f55d7f08632f
comparison
equal deleted inserted replaced
446:72ef6e809f79 447:8f46ba2f1b81
1 {% extends 'base.html' %}
2 {% load url from future %}
3 {% load comment_tags %}
4 {% load script_tags %}
5 {% block title %}Poll Results: {{ poll.question }}{% endblock %}
6 {% block custom_css %}
7 <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/polls.css" />
8 {% endblock %}
9 {% block custom_js %}
10 {% if poll.is_open %}
11 <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/comments.css" />
12 {% script_tags "markitup jquery-ui" %}
13 <script type="text/javascript" src="{{ STATIC_URL }}js/comments.js"></script>
14 {% endif %}
15 {% endblock %}
16 {% block content %}
17 <h2>Polls</h2>
18 <h3>Results for: {{ poll.question }}</h3>
19 <dl class="poll-result">
20 {% for choice in choices %}
21 <dt>{{ choice.choice }} - {{ choice.pct|floatformat }}% ({{ choice.votes }} vote{{ choice.votes|pluralize }})</dt>
22 <dd>
23 <div class="poll-percent" style="width: {{ choice.pct|floatformat:0 }}%; background-color: teal; color: white;">
24 <span>&nbsp;</span></div>
25 </dd>
26 {% endfor %}
27 </dl>
28 <p><strong>{{ total_votes }} total vote{{ total_votes|pluralize }}.</strong></p>
29
30 {% if user_choice %}
31 <p>You voted for &quot;{{ user_choice.choice }}&quot;.</p>
32 {% endif %}
33
34 <p>
35 {% if poll.is_open %}
36 Voting for this poll started on {{ poll.start_date|date:"F d, Y" }}.
37 {% if poll.end_date %}
38 Voting will end on {{ poll.end_date|date:"F d, Y" }}.
39 {% endif %}
40 {% else %}
41 This poll ran from {{ poll.start_date|date:"F d, Y" }} to {{ poll.end_date|date:"F d, Y" }}.
42 {% endif %}
43 </p>
44
45 <p class="poll-nav">
46 {% if poll.is_open and user.is_authenticated %}
47 <a href="{% url 'polls-vote' poll_id=poll.id %}">Vote</a>
48 {% endif %}
49 | <a href="{% url 'polls-main' %}">All Polls</a>
50 </p>
51
52 {% get_comment_count for poll as comment_count %}
53 <p>This poll has <span id="comment-count">{{ comment_count }}</span> comment{{ comment_count|pluralize }}.</p>
54 <hr />
55 {% render_comment_list poll %}
56 {% if poll.is_open %}
57 <p>Leave a comment?</p>
58 {% render_comment_form for poll %}
59 {% else %}
60 <p>Comments are closed for this poll. If you'd like to share your thoughts on this poll
61 with the site staff, you can <a href="{% url 'contact-form' %}">contact us directly</a>.</p>
62 {% endif %}
63 {% endblock %}