cmsplugin-poll / cmsplugin_poll / templatetags / poll_tags.py

Diff from to

cmsplugin_poll/templatetags/poll_tags.py

 
 register = Library()
 
+
 @register.simple_tag
 def get_latest_polls(count=5):
     "FIXME: I'm useless!"
     polls = Poll.objects.all()[:5]
     return render_to_string("cmsplugin_poll/latest_polls.html", {
-            "polls" : polls
+            "polls": polls
             })
 
+
 @register.simple_tag
 def get_choice_rate(poll, choice):
     return "%d%%" % poll.getrate(choice)
+
+
+@register.assignment_tag
+def show_results(request, poll):
+    poll_is_closed = poll.close_date is not None
+    session_has_voted = request.session.get("poll_%d" % poll.id, False)
+    return poll_is_closed or session_has_voted
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.