Cleaning: timezone issues, deprecated urls.py imports, missing notes.
[wolnelektury.git] / apps / polls / templatetags / polls_tags.py
1 # -*- coding: utf-8 -*-
2 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
4 #
5 from django import template
6 from ..forms import PollForm
7
8
9 register = template.Library()
10
11 @register.inclusion_tag('polls/tags/poll.html', takes_context = True)
12 def poll(context, poll, show_results = True, redirect_to = ''):
13     form = None
14     voted_already = poll.voted(context.get('request').session)
15     if not voted_already:
16         form = PollForm(poll = poll, initial = dict(redirect_to = redirect_to))
17     return dict(poll = poll,
18                 form = form,
19                 voted_already = voted_already,
20                 vote_count = poll.vote_count,
21                 show_results = show_results
22            )