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

paginated stats, tweaked voter data structure to hash the voter_id for...

paginated stats, tweaked voter data structure to hash the voter_id for privacy, still testing that latter thing
parent 28470e75
Branches
Tags
No related merge requests found
......@@ -428,7 +428,7 @@ class Voter(HeliosObject):
A voter in an election
"""
FIELDS = ['election_uuid', 'uuid', 'voter_type', 'voter_id', 'name', 'alias']
JSON_FIELDS = ['election_uuid', 'uuid', 'voter_type', 'voter_id', 'name']
JSON_FIELDS = ['election_uuid', 'uuid', 'voter_type', 'voter_id_hash', 'name']
# alternative, for when the voter is aliased
ALIASED_VOTER_JSON_FIELDS = ['election_uuid', 'uuid', 'alias']
......@@ -440,6 +440,10 @@ class Voter(HeliosObject):
else:
return super(Voter,self).toJSONDict()
@property
def voter_id_hash(self):
return utils.hash_b64(self.voter_id)
class Trustee(HeliosObject):
"""
a trustee
......
......@@ -4,6 +4,18 @@
{% block content %}
<h1>Statistics</h1>
<p>
{% if elections_page.has_previous %}
<a href="?page={{elections_page.previous_page_number}}&limit={{limit}}">previous {{limit}}</a> &nbsp;&nbsp;
{% endif %}
Elections {{elections_page.start_index}} - {{elections_page.end_index}}&nbsp;&nbsp;
{% if elections_page.has_next %}
<a href="?page={{elections_page.next_page_number}}&limit={{limit}}">next {{limit}}</a> &nbsp;&nbsp;
{% endif %}
</p>
{% for election in elections %}
<p>
<b><a href="{% url helios.views.one_election_view election.uuid %}">{{election.name}}</a></b> -- {{election.num_voters}} voters
......
......@@ -68,9 +68,15 @@ def stats(request):
if not user or not user.admin_p:
raise PermissionDenied()
elections = Election.objects.all().order_by('-created_at')[:25]
page = int(request.GET.get('page', 1))
limit = int(request.GET.get('limit', 25))
elections = Election.objects.all().order_by('-created_at')
elections_paginator = Paginator(elections, limit)
elections_page = elections_paginator.page(page)
return render_template(request, "stats", {'elections' : elections})
return render_template(request, "stats", {'elections' : elections_page.object_list, 'elections_page': elections_page
'limit' : limit})
##
## General election features
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment