Permalink
Browse files

Merge pull request #168 from benadida/upgrade-django-18

Upgrade django 18
  • Loading branch information...
benadida committed Jun 10, 2017
2 parents 44f26cd + 8853b9a commit 8cc0c5a2019737d22024dc967c38d814e199c77a
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('helios', '0003_auto_20160507_1948'),
]
operations = [
migrations.AlterField(
model_name='election',
name='help_email',
field=models.EmailField(max_length=254, null=True),
),
migrations.AlterField(
model_name='trustee',
name='email',
field=models.EmailField(max_length=254),
),
]
View
@@ -817,9 +817,9 @@ class Meta:
def __init__(self, *args, **kwargs):
super(Voter, self).__init__(*args, **kwargs)
def get_user(self):
# stub the user so code is not full of IF statements
if not self.user:
self.user = User(user_type='password', user_id=self.voter_email, name=self.voter_name)
return self.user or User(user_type='password', user_id=self.voter_email, name=self.voter_name)
@classmethod
@transaction.atomic
@@ -920,11 +920,11 @@ def election_uuid(self):
@property
def name(self):
return self.user.name
return self.get_user().name
@property
def voter_id(self):
return self.user.user_id
return self.get_user().user_id
@property
def voter_id_hash(self):
@@ -945,14 +945,17 @@ def voter_id_hash(self):
@property
def voter_type(self):
return self.user.user_type
return self.get_user().user_type
@property
def display_html_big(self):
return self.user.display_html_big
return self.get_user().display_html_big
def send_message(self, subject, body):
self.user.send_message(subject, body)
self.get_user().send_message(subject, body)
def can_update_status(self):
return self.get_user().can_update_status()
def generate_password(self, length=10):
if self.voter_password:
View
@@ -22,7 +22,7 @@ def cast_vote_verify_and_store(cast_vote_id, status_update_message=None, **kwarg
voter = cast_vote.voter
election = voter.election
user = voter.user
user = voter.get_user()
if result:
# send the signal
@@ -71,7 +71,7 @@ def single_voter_email(voter_uuid, subject_template, body_template, extra_vars={
subject = render_template_raw(None, subject_template, the_vars)
body = render_template_raw(None, body_template, the_vars)
voter.user.send_message(subject, body)
voter.send_message(subject, body)
@task()
def single_voter_notify(voter_uuid, notification_template, extra_vars={}):
@@ -82,7 +82,7 @@ def single_voter_notify(voter_uuid, notification_template, extra_vars={}):
notification = render_template_raw(None, notification_template, the_vars)
voter.user.send_notification(notification)
voter.send_notification(notification)
@task()
def election_compute_tally(election_id):
@@ -10,7 +10,7 @@ <h2 class="title">{{election.name}} &mdash; Compute Tally <span style="font-size
<form method="POST" action="">
<input type="hidden" name="csrf_token" value="{{csrf_token}}" />
<input type="submit" value="compute the tally!" />
<input type="submit" class="button" value="compute the tally!" />
</form>
{% endblock %}
@@ -18,7 +18,7 @@ <h2 class="title">Compute Tally for Election: {{election.name}}</h2>
<form method="post" action="" onsubmit="alert('ok, tally has begun')" class="pretty">
<input type="hidden" name="csrf_token" value="{{csrf_token}}" />
<input class="pretty" type="submit" value="compute encrypted tally!" />
<input class="button" type="submit" value="compute encrypted tally!" />
<button onclick="document.location='./view'; return false;">never mind</button>
</form>
{% else %}
@@ -13,7 +13,7 @@ <h2 class="title">{{election.name}} &mdash; Release Result <span style="font-siz
<p>
<input type="checkbox" name="send_email" value="send_email" checked="checked"/> Send email to voters reporting release of result.
</p>
<input type="submit" value="release result!" />
<input type="submit" class="button" value="release result!" />
</form>
{% endblock %}
View
@@ -250,7 +250,7 @@ def test_create_password_voter(self):
self.assertRaises(Exception, lambda: v.generate_password())
# check that you can get at the voter user structure
self.assertEquals(v.user.user_id, v.voter_email)
self.assertEquals(v.get_user().user_id, v.voter_email)
class CastVoteModelTests(TestCase):
@@ -424,8 +424,8 @@ def setup_login(self):
# set up the app, too
# this does not appear to work, boohoo
session = self.app.session
session['user'] = {'type': self.user.user_type, 'user_id': self.user.user_id}
#session = self.app.session
#session['user'] = {'type': self.user.user_type, 'user_id': self.user.user_id}
def clear_login(self):
session = self.client.session
@@ -642,7 +642,7 @@ def _cast_ballot(self, election_id, username, password, need_login=True, check_u
self.assertRedirects(response, "%s/helios/elections/%s/cast_confirm" % (settings.SECURE_URL_HOST, election_id))
cast_confirm_page = response.follow()
if need_login:
if check_user_logged_in:
self.assertContains(cast_confirm_page, "You are logged in as")
@@ -653,12 +653,7 @@ def _cast_ballot(self, election_id, username, password, need_login=True, check_u
login_form['voter_id'] = username
login_form['password'] = password
# we skip that intermediary page now
# cast_confirm_page = login_form.submit()
response = login_form.submit()
# self.assertRedirects(cast_confirm_page, "/helios/elections/%s/cast_confirm" % election_id)
# cast_confirm_page = cast_confirm_page.follow()
else:
# here we should be at the cast-confirm page and logged in
self.assertContains(cast_confirm_page, "CAST this ballot")
@@ -751,7 +746,7 @@ def test_do_complete_election(self):
## for now the above does not work, it's a testing problem
## where the cookie isn't properly set. We'll have to figure this out.
## FIXME FIXME FIXME
# self._cast_ballot(election_id, username, password, check_user_logged_in=True)
#self._cast_ballot(election_id, username, password, check_user_logged_in=True)
self._cast_ballot(election_id, username, password, check_user_logged_in=False)
self.clear_login()
View
@@ -622,7 +622,7 @@ def one_election_cast_confirm(request, election):
return render_template(request, 'election_not_started', {'election': election})
voter = get_voter(request, user, election)
# auto-register this person if the election is openreg
if user and not voter and election.openreg:
voter = _register_voter(election, user)
@@ -677,7 +677,7 @@ def one_election_cast_confirm(request, election):
bad_voter_login = (request.GET.get('bad_voter_login', "0") == "1")
# status update this vote
if voter and voter.user.can_update_status():
if voter and voter.can_update_status():
status_update_label = voter.user.update_status_template() % "your smart ballot tracker"
status_update_message = "I voted in %s - my smart tracker is %s.. #heliosvoting" % (get_election_url(election),cast_vote.vote_hash[:10])
else:
@@ -761,7 +761,8 @@ def one_election_cast_done(request, election):
# only log out if the setting says so *and* we're dealing
# with a site-wide voter. Definitely remove current_voter
if voter.user == user:
# checking that voter.user != None is needed because voter.user may now be None if voter is password only
if voter.user == user and voter.user != None:
logout = settings.LOGOUT_ON_CONFIRMATION
else:
logout = False
View
@@ -1,4 +1,4 @@
Django==1.7.10
Django==1.8.18
anyjson==0.3.3
celery==3.1.18
django-celery==3.1.16

0 comments on commit 8cc0c5a

Please sign in to comment.