X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/99f6dd4f1ff0390de9a9bbd4e3352b953cb9a235..0e9ce396fab5cdfc2f1806bae43f05de77cb1e21:/apps/polls/views.py diff --git a/apps/polls/views.py b/apps/polls/views.py index 1dcd38767..ef5f50f5e 100644 --- a/apps/polls/views.py +++ b/apps/polls/views.py @@ -7,22 +7,22 @@ from django.shortcuts import get_object_or_404, redirect, render_to_response from django.core.urlresolvers import reverse from django.template import RequestContext -from models import Poll, PollItem -from forms import PollForm +from .models import Poll, PollItem +from .forms import PollForm @require_http_methods(['GET', 'POST']) def poll(request, slug): - - poll = get_object_or_404(Poll, slug = slug, open = True) - + + poll = get_object_or_404(Poll, slug=slug, open=True) + if request.method == 'POST': redirect_to = reverse('poll', args = [slug]) form = PollForm(request.POST, poll = poll) if form.is_valid(): if not poll.voted(request.session): try: - poll_item = PollItem.objects.filter(pk = form.cleaned_data['vote'], poll = poll).get() + poll_item = PollItem.objects.filter(pk=form.cleaned_data['vote'], poll=poll).get() except PollItem.DoesNotExist: pass else: @@ -33,6 +33,3 @@ def poll(request, slug): context['poll'] = poll context['voted_already'] = poll.voted(request.session) return render_to_response('polls/poll.html', context) - - -