cmsplugin-poll / cmsplugin_poll / views.py

Diff from to

cmsplugin_poll/views.py

 from django.shortcuts import render_to_response, get_object_or_404
-from django.http import HttpResponseRedirect, HttpResponse
+from django.http import HttpResponseRedirect
 from django.core.urlresolvers import reverse
 from django.template import RequestContext
 from django.contrib import messages
 from django.utils.translation import ugettext_lazy as _
-from models import *
+from models import Poll, Choice
+
 
 def index(request):
-    polls = Poll.objects.all().order_by("-pub_date")
+    polls = Poll.objects.iterator()
     return render_to_response("cmsplugin_poll/latest_polls.html", {
-            "polls" : polls
+            "polls": polls
             })
 
+
 def detail(request, poll_id):
     p = get_object_or_404(Poll, pk=poll_id)
-    return render_to_response("cmsplugin_poll/detail.html", {"poll" : p},
+    return render_to_response("cmsplugin_poll/detail.html", {"poll": p},
                               context_instance=RequestContext(request))
 
+
 def vote(request, poll_id):
     p = get_object_or_404(Poll, pk=poll_id)
     if p.close_date is not None:
             selected_choice.save()
             messages.info(request, _("Thank you for your vote"))
             request.session["poll_%d" % p.id] = True
-    return HttpResponseRedirect(reverse('cmsplugin_poll.views.results', 
+    return HttpResponseRedirect(reverse('cmsplugin_poll.views.results',
                                         args=(p.id,)))
 
+
 def results(request, poll_id):
     p = get_object_or_404(Poll, pk=poll_id)
     return render_to_response('cmsplugin_poll/results.html', {'poll': p},
                               context_instance=RequestContext(request))
-
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.