Mercurial > public > sg101
changeset 367:cb121a3abf46
Fixing #176; add a side block for current polls.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 05 Mar 2011 20:54:26 +0000 |
parents | 5219c7cc5a53 |
children | b76af55aafe4 |
files | gpp/polls/models.py gpp/polls/templatetags/poll_tags.py gpp/templates/base.html gpp/templates/polls/latest_poll_block_tag.html |
diffstat | 4 files changed, 28 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/gpp/polls/models.py Sat Mar 05 19:40:31 2011 +0000 +++ b/gpp/polls/models.py Sat Mar 05 20:54:26 2011 +0000 @@ -1,7 +1,7 @@ -''' +""" Models for the Polls application. -''' +""" import datetime from django.db import models from django.db.models import Q @@ -30,7 +30,7 @@ start_date = models.DateTimeField(db_index=True, help_text='Date/time the poll will be eligible for voting.',) end_date = models.DateTimeField(blank=True, null=True, db_index=True, - help_text='Date/time the poll will be ineligible for voting. '\ + help_text='Date/time the poll will be ineligible for voting. ' 'Leave blank for an open ended poll.') is_enabled = models.BooleanField(default=True, db_index=True, help_text='Check to allow the poll to be viewed on the site.')
--- a/gpp/polls/templatetags/poll_tags.py Sat Mar 05 19:40:31 2011 +0000 +++ b/gpp/polls/templatetags/poll_tags.py Sat Mar 05 20:54:26 2011 +0000 @@ -1,5 +1,5 @@ """ -Template tags for the Polls application. +Template tags for the Polls application. """ from django import template @@ -15,4 +15,10 @@ except IndexError: poll = None - return {'poll': poll } + return {'poll': poll} + + +@register.inclusion_tag("polls/latest_poll_block_tag.html") +def latest_poll_block(): + polls = Poll.objects.get_current_polls() + return {'polls': polls}
--- a/gpp/templates/base.html Sat Mar 05 19:40:31 2011 +0000 +++ b/gpp/templates/base.html Sat Mar 05 20:54:26 2011 +0000 @@ -8,6 +8,7 @@ {% load potd_tags %} {% load messages_tags %} {% load script_tags %} +{% load poll_tags %} {% load cache %} <head><title>SurfGuitar101.com | {% block title %}{% endblock %}</title> <meta http-equiv="Content-Type" content="text/html" /> @@ -80,6 +81,7 @@ {% cache 60 irc_block %} {% irc_status %} {% endcache %} + {% latest_poll_block %} {% include 'core/mp3comp_block.html' %} </div>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gpp/templates/polls/latest_poll_block_tag.html Sat Mar 05 20:54:26 2011 +0000 @@ -0,0 +1,15 @@ +{% extends 'side_block.html' %} +{% load url from future %} +{% block block_title %}Current Polls{% endblock %} +{% block block_content %} +{% if polls %} +<ul> + {% for poll in polls %} + <li><a href="{{ poll.get_absolute_url }}">{{ poll.question }}</a></li> + {% endfor %} +</ul> +{% else %} +<p class="centered">No polls at this time. Check out our +<a href="{% url 'polls-main' %}">past polls</a>.</p> +{% endif %} +{% endblock %}