Skip to content
Snippets Groups Projects
Commit 383f0102 authored by Ben Adida's avatar Ben Adida
Browse files

efficiency fixes, UTC indication

parent 8a301316
No related branches found
No related tags found
No related merge requests found
...@@ -92,7 +92,7 @@ def admin_required(func): ...@@ -92,7 +92,7 @@ def admin_required(func):
# get the user # get the user
def get_user(request): def get_user(request):
# push the expiration of the session back # push the expiration of the session back
request.session.set_expiry(settings.SESSION_COOKIE_AGE) # request.session.set_expiry(settings.SESSION_COOKIE_AGE)
# set up CSRF protection if needed # set up CSRF protection if needed
if not request.session.has_key('csrf_token') or type(request.session['csrf_token']) != str: if not request.session.has_key('csrf_token') or type(request.session['csrf_token']) != str:
......
...@@ -152,7 +152,7 @@ class Election(models.Model, electionalgs.Election): ...@@ -152,7 +152,7 @@ class Election(models.Model, electionalgs.Election):
@classmethod @classmethod
def get_by_uuid(cls, uuid): def get_by_uuid(cls, uuid):
try: try:
return cls.objects.get(uuid=uuid) return cls.objects.select_related().get(uuid=uuid)
except cls.DoesNotExist: except cls.DoesNotExist:
return None return None
...@@ -599,7 +599,7 @@ class Voter(models.Model, electionalgs.Voter): ...@@ -599,7 +599,7 @@ class Voter(models.Model, electionalgs.Voter):
@classmethod @classmethod
def get_by_user(cls, user): def get_by_user(cls, user):
return cls.objects.filter(voter_type = user.user_type, voter_id = user.user_id).order_by('-cast_at') return cls.objects.select_related().filter(voter_type = user.user_type, voter_id = user.user_id).order_by('-cast_at')
@property @property
def user(self): def user(self):
......
...@@ -165,12 +165,12 @@ For your privacy, you'll be asked to log in only once your ballot is encrypted. ...@@ -165,12 +165,12 @@ For your privacy, you'll be asked to log in only once your ballot is encrypted.
{% endif %} {% endif %}
{% if election.voting_extended_until %} {% if election.voting_extended_until %}
<br /> <br />
This election was initially scheduled to end at {{election.voting_ends_at}},<br /> This election was initially scheduled to end at {{election.voting_ends_at}} (UTC),<br />
but has been extended until {{ election.voting_extended_until }}. but has been extended until {{ election.voting_extended_until }} (UTC).
{% else %} {% else %}
{% if election.voting_ends_at %} {% if election.voting_ends_at %}
<br /> <br />
This election is scheduled to end at {{election.voting_ends_at}}. This election is scheduled to end at {{election.voting_ends_at}} (UTC).
{% else %} {% else %}
<br /> <br />
This election ends at the administrator's discretion. This election ends at the administrator's discretion.
......
...@@ -898,11 +898,11 @@ def voters_list_pretty(request, election): ...@@ -898,11 +898,11 @@ def voters_list_pretty(request, election):
else: else:
voters = voters.filter(name__icontains = q) voters = voters.filter(name__icontains = q)
total_voters = voters.count()
voter_paginator = Paginator(voters, limit) voter_paginator = Paginator(voters, limit)
voters_page = voter_paginator.page(page) voters_page = voter_paginator.page(page)
total_voters = voter_paginator.count
return render_template(request, 'voters_list', {'election': election, 'voters_page': voters_page, return render_template(request, 'voters_list', {'election': election, 'voters_page': voters_page,
'voters': voters_page.object_list, 'admin_p': admin_p, 'voters': voters_page.object_list, 'admin_p': admin_p,
'email_voters': helios.VOTERS_EMAIL, 'email_voters': helios.VOTERS_EMAIL,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment