Django 1.7, working version.
[wolnelektury.git] / apps / polls / views.py
index 1dcd387..ef5f50f 100644 (file)
@@ -7,22 +7,22 @@ from django.shortcuts import get_object_or_404, redirect, render_to_response
 from django.core.urlresolvers import reverse\r
 from django.template import RequestContext
 
 from django.core.urlresolvers import reverse\r
 from django.template import RequestContext
 
-from models import Poll, PollItem\r
-from forms import PollForm
+from .models import Poll, PollItem\r
+from .forms import PollForm
 
 \r
 @require_http_methods(['GET', 'POST'])\r
 def poll(request, slug):
 
 \r
 @require_http_methods(['GET', 'POST'])\r
 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':\r
         redirect_to = reverse('poll', args = [slug])
         form = PollForm(request.POST, poll = poll)\r
         if form.is_valid():\r
             if not poll.voted(request.session):\r
                 try:\r
     if request.method == 'POST':\r
         redirect_to = reverse('poll', args = [slug])
         form = PollForm(request.POST, poll = poll)\r
         if form.is_valid():\r
             if not poll.voted(request.session):\r
                 try:\r
-                    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:\r
                     pass\r
                 else:\r
                 except PollItem.DoesNotExist:\r
                     pass\r
                 else:\r
@@ -33,6 +33,3 @@ def poll(request, slug):
         context['poll'] = poll\r
         context['voted_already'] = poll.voted(request.session)
         return render_to_response('polls/poll.html', context)
         context['poll'] = poll\r
         context['voted_already'] = poll.voted(request.session)
         return render_to_response('polls/poll.html', context)
-        
-        \r
-