Mercurial > public > sg101
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gpp/templates/polls/poll_detail.html Sat Jun 25 23:23:20 2011 +0000 @@ -0,0 +1,63 @@ +{% extends 'base.html' %} +{% load url from future %} +{% load comment_tags %} +{% load script_tags %} +{% block title %}Poll Results: {{ poll.question }}{% endblock %} +{% block custom_css %} +<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/polls.css" /> +{% endblock %} +{% block custom_js %} +{% if poll.is_open %} +<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/comments.css" /> +{% script_tags "markitup jquery-ui" %} +<script type="text/javascript" src="{{ STATIC_URL }}js/comments.js"></script> +{% endif %} +{% endblock %} +{% block content %} +<h2>Polls</h2> +<h3>Results for: {{ poll.question }}</h3> +<dl class="poll-result"> +{% for choice in choices %} + <dt>{{ choice.choice }} - {{ choice.pct|floatformat }}% ({{ choice.votes }} vote{{ choice.votes|pluralize }})</dt> + <dd> + <div class="poll-percent" style="width: {{ choice.pct|floatformat:0 }}%; background-color: teal; color: white;"> + <span> </span></div> + </dd> +{% endfor %} +</dl> +<p><strong>{{ total_votes }} total vote{{ total_votes|pluralize }}.</strong></p> + +{% if user_choice %} +<p>You voted for "{{ user_choice.choice }}".</p> +{% endif %} + +<p> +{% if poll.is_open %} +Voting for this poll started on {{ poll.start_date|date:"F d, Y" }}. + {% if poll.end_date %} + Voting will end on {{ poll.end_date|date:"F d, Y" }}. + {% endif %} +{% else %} +This poll ran from {{ poll.start_date|date:"F d, Y" }} to {{ poll.end_date|date:"F d, Y" }}. +{% endif %} +</p> + +<p class="poll-nav"> +{% if poll.is_open and user.is_authenticated %} +<a href="{% url 'polls-vote' poll_id=poll.id %}">Vote</a> +{% endif %} +| <a href="{% url 'polls-main' %}">All Polls</a> +</p> + +{% get_comment_count for poll as comment_count %} +<p>This poll has <span id="comment-count">{{ comment_count }}</span> comment{{ comment_count|pluralize }}.</p> +<hr /> +{% render_comment_list poll %} +{% if poll.is_open %} +<p>Leave a comment?</p> +{% render_comment_form for poll %} +{% else %} +<p>Comments are closed for this poll. If you'd like to share your thoughts on this poll +with the site staff, you can <a href="{% url 'contact-form' %}">contact us directly</a>.</p> +{% endif %} +{% endblock %}