Skip to content

Commit

Permalink
fixed views, fixed eligibility legacy objects
Browse files Browse the repository at this point in the history
  • Loading branch information
benadida committed Feb 15, 2011
1 parent c5fb180 commit 3934b46
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 32 deletions.
5 changes: 2 additions & 3 deletions helios/datatypes/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,5 @@ class Tally(LegacyObject):
STRUCTURED_FIELDS = {
'tally': arrayOf(arrayOf('legacy/EGCiphertext'))}


class Eligibility(LegacyObject):
pass
class Eligibility(ListObject, LegacyObject):
WRAPPED_OBJ = list
4 changes: 2 additions & 2 deletions helios/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,8 @@ def set_eligibility(self):
return

auth_systems = copy.copy(settings.AUTH_ENABLED_AUTH_SYSTEMS)
voter_types = [r['user__user_type'] for r in self.voter_set.values('user__user_type').distinct()]
voter_types = [r['user__user_type'] for r in self.voter_set.values('user__user_type').distinct() if r['user__user_type'] != None]

# password is now separate, not an explicit voter type
if self.voter_set.filter(user=None).count() > 0:
voter_types.append('password')
Expand Down
13 changes: 13 additions & 0 deletions helios/templates/_castconfirm_docast.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{% if election.voting_has_started %}
{% if not election.voting_has_stopped %}

<div id="cast_form">
<form method="post" action="" onsubmit="show_waiting()">
<input type="hidden" name="csrf_token" value="{{csrf_token}}" />
Expand Down Expand Up @@ -28,3 +31,13 @@
Verifying and Casting your ballot<br />
<img src="/static/helios/loading.gif" />
</div>
{% else %}
<p style="font-size:1.4em;">
voting has stopped, sorry.
</p>
{% endif %}
{% else %}
<p style="font-size:1.4em;">
voting has not yet begun, sorry.
</p>
{% endif %}
34 changes: 7 additions & 27 deletions helios/templates/election_cast_confirm.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,34 +42,18 @@ <h1>{{election.name}} &mdash; Submit your Vote</h1>
<tt style="font-size:1.8em; font-weight: bold; padding-left: 20px;"> {{vote_fingerprint}}</tt>
</p>

{% if password_only %}
{% if voter %}
{% include "_castconfirm_docast.html" %}
{% else %}
{% include "_castconfirm_password.html" %}
{% endif %}
{% else %}

{% include "_castconfirm_docast.html" %}

{% if user %}
{% else %}

{% if voter %}
{% if show_password %}
{% include "_castconfirm_password.html" %}

{% if election.voting_has_started %}
{% if not election.voting_has_stopped %}
{% include "_castconfirm_docast.html" %}
{% else %}
<p style="font-size:1.4em;">
voting has stopped, sorry.
</p>
{% endif %}
{% else %}
<p style="font-size:1.4em;">
voting has not yet begun, sorry.
</p>
{% endif %}

{% else %}
{% if user %}
<p>
{% if election.openreg %}
<b>Sorry, you are <em><u>not eligible</u></em> for this election.</b><br />
Expand All @@ -80,8 +64,6 @@ <h1>{{election.name}} &mdash; Submit your Vote</h1>
<p>
[<a href="{% url helios.views.one_election_view election.uuid %}">return to the main election page</a>]
</p>
{% endif %}

{% else %}
<p>
Now, we need you to log in, so we can verify your eligibility.<br /><br />
Expand All @@ -98,16 +80,14 @@ <h1>{{election.name}} &mdash; Submit your Vote</h1>
{% endif %}
</p>

{% if show_password %}
{% include "_castconfirm_password.html" %}
{% endif %}

{{login_box|safe}}

<br />
Don't worry, we'll remember your ballot while you log in.
{% endif %}

{% endif %}

{# this closes the IF ELSE of this being password_only #}
{% endif %}

Expand Down
5 changes: 5 additions & 0 deletions helios/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ def test_eligibility(self):
# without openreg, this should be false
self.assertFalse(self.election.user_eligible_p(self.user))

# what about after saving?
self.election.save()
e = models.Election.objects.get(uuid = self.election.uuid)
self.assertEquals(e.eligibility, [{'auth_system': self.user.user_type}])

self.election.openreg = True

# without openreg, and now true
Expand Down
1 change: 1 addition & 0 deletions helios/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ def one_election_cast_confirm(request, election):
auth_systems = None

password_only = False

if auth_systems == None or 'password' in auth_systems:
show_password = True
password_login_form = forms.VoterPasswordForm()
Expand Down

0 comments on commit 3934b46

Please sign in to comment.