From 1b55696f2a94d5e962fdd17b529a760d306f03e8 Mon Sep 17 00:00:00 2001 From: hedleyroos Date: Wed, 4 Dec 2013 09:40:35 +0200 Subject: [PATCH 1/2] Performance improvements --- CHANGELOG.rst | 4 ++++ poll/models.py | 7 ++++--- poll/templatetags/poll_tags.py | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 68b7160..774fa10 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,10 @@ Changelog ========= +next +---- +#. Performance improvements. + 0.1.1 ----- #. Add caching to detail and widget templates. diff --git a/poll/models.py b/poll/models.py index bc9cc94..21fe8d2 100644 --- a/poll/models.py +++ b/poll/models.py @@ -48,10 +48,11 @@ def can_vote_on_poll(self, request): object_id__in=[o.id for o in self.polloption_set.all()], token=request.secretballot_token ) - if votes.count() == 0: - return True, 'can_vote' - else: + if votes.exists(): return False, 'voted' + else: + return True, 'can_vote' + @property def vote_count(self): diff --git a/poll/templatetags/poll_tags.py b/poll/templatetags/poll_tags.py index a12aca5..3f0edc7 100644 --- a/poll/templatetags/poll_tags.py +++ b/poll/templatetags/poll_tags.py @@ -17,8 +17,8 @@ def poll_detail(context, obj): 'object': obj, 'can_vote_on_poll': can_vote_on_poll, 'reason': reason - }) - if not context.has_key('form'): + }) + if can_vote_on_poll and not context.has_key('form'): context['form'] = PollVoteForm(request=context['request'], poll=obj) return context From fbb365eb9319e4f1f4906eb3661e7cdb17373fb0 Mon Sep 17 00:00:00 2001 From: hedleyroos Date: Thu, 12 Dec 2013 10:28:24 +0200 Subject: [PATCH 2/2] Prep for release --- CHANGELOG.rst | 4 ++-- setup.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 774fa10..08e59f3 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,8 +1,8 @@ Changelog ========= -next ----- +0.1.2 +----- #. Performance improvements. 0.1.1 diff --git a/setup.py b/setup.py index 2f224c9..ec72d20 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name='jmbo-poll', - version='0.1.1', + version='0.1.2', description='Polling app for Jmbo.', long_description=open('README.rst', 'r').read() + open('AUTHORS.rst', 'r').read() + open('CHANGELOG.rst', 'r').read(), author='Praekelt Foundation',