Skip to content

Commit

Permalink
Merge pull request #82 from benadida/update-to-django-1.6
Browse files Browse the repository at this point in the history
update to django 1.6
  • Loading branch information
benadida committed Jan 26, 2015
2 parents d61f5db + 7057193 commit b07c43d
Show file tree
Hide file tree
Showing 65 changed files with 164 additions and 174 deletions.
8 changes: 3 additions & 5 deletions helios/crypto/utils.py
Expand Up @@ -2,9 +2,7 @@
Crypto Utils
"""

import hmac, base64

from django.utils import simplejson
import hmac, base64, json

from hashlib import sha256

Expand All @@ -18,8 +16,8 @@ def hash_b64(s):
return result

def to_json(d):
return simplejson.dumps(d, sort_keys=True)
return json.dumps(d, sort_keys=True)

def from_json(json_str):
if not json_str: return None
return simplejson.loads(json_str)
return json.loads(json_str)
2 changes: 1 addition & 1 deletion helios/datatypes/djangofield.py
Expand Up @@ -7,10 +7,10 @@
"""

import datetime
import json
from django.db import models
from django.db.models import signals
from django.conf import settings
from django.utils import simplejson as json
from django.core.serializers.json import DjangoJSONEncoder

from . import LDObject
Expand Down
2 changes: 1 addition & 1 deletion helios/datatypes/legacy.py
Expand Up @@ -176,7 +176,7 @@ class DLogProof(LegacyObject):

def __init__(self, wrapped_obj):
if isinstance(wrapped_obj, dict):
import pdb; pdb.set_trace()
raise Exception("problem with dict")

super(DLogProof,self).__init__(wrapped_obj)

Expand Down
2 changes: 1 addition & 1 deletion helios/election_urls.py
Expand Up @@ -4,7 +4,7 @@
Ben Adida (ben@adida.net)
"""

from django.conf.urls.defaults import *
from django.conf.urls import *

from helios.views import *

Expand Down
2 changes: 1 addition & 1 deletion helios/models.py
Expand Up @@ -7,7 +7,7 @@
"""

from django.db import models, transaction
from django.utils import simplejson
import json
from django.conf import settings
from django.core.mail import send_mail

Expand Down
4 changes: 2 additions & 2 deletions helios/security.py
Expand Up @@ -26,8 +26,8 @@ def get_voter(request, user, election):
return the current voter
"""
voter = None
if request.session.has_key('CURRENT_VOTER'):
voter = request.session['CURRENT_VOTER']
if request.session.has_key('CURRENT_VOTER_ID'):
voter = Voter.objects.get(id=request.session['CURRENT_VOTER_ID'])
if voter.election != election:
voter = None

Expand Down
2 changes: 1 addition & 1 deletion helios/stats_urls.py
Expand Up @@ -4,7 +4,7 @@
Ben Adida (ben@adida.net)
"""

from django.conf.urls.defaults import *
from django.conf.urls import *

from helios.stats_views import *

Expand Down
2 changes: 1 addition & 1 deletion helios/templates/_castconfirm_password.html
@@ -1,5 +1,5 @@
Please provide the voter ID and password you received by email.<br /><br />
<form method="post" action="{% url helios.views.password_voter_login election.uuid %}" onsubmit="show_waiting()">
<form method="post" action="{% url "helios.views.password_voter_login" election.uuid %}" onsubmit="show_waiting()">
<input type="hidden" name="csrf_token" value="{{csrf_token}}" />
<input type="hidden" name="return_url" value="{{return_url}}" />
<input type="hidden" name="cast_ballot" value="{{cast_ballot}}" />
Expand Down
2 changes: 1 addition & 1 deletion helios/templates/cast_done.html
Expand Up @@ -24,7 +24,7 @@ <h1>{{election.name}} &mdash; Vote Successfully Cast!</h1>
{% endif %}

<p style="font-size: 1.4em;">
[ <a href="{% url helios.views.one_election_view election.uuid %}">return to election info</a> ]
[ <a href="{% url "helios.views.one_election_view" election.uuid %}">return to election info</a> ]
</p>

{% endblock %}
2 changes: 1 addition & 1 deletion helios/templates/castvote.html
Expand Up @@ -3,7 +3,7 @@
{% block title %}{{cast_vote.vote_tinyhash}} &mdash; {{election.name}}{% endblock %}
{% block content %}
<h2 class="title">Cast Vote {{cast_vote.vote_tinyhash}}</h2>
cast in <a href="{% url helios.views.one_election_view election.uuid %}">{{election.name}}</a><br />
cast in <a href="{% url "helios.views.one_election_view" election.uuid %}">{{election.name}}</a><br />
Fingerprint: <tt>{{cast_vote.vote_hash}}</tt><br />
by <b><u>
{% if the_voter.alias %}
Expand Down
2 changes: 1 addition & 1 deletion helios/templates/combine_decryptions.html
Expand Up @@ -2,7 +2,7 @@

{% block title %}Compute Tally &mdash; {{election.name}}{% endblock %}
{% block content %}
<h2 class="title">{{election.name}} &mdash; Compute Tally <span style="font-size:0.7em;">[<a href="{% url helios.views.one_election_view election.uuid %}">cancel</a>]</span></h2>
<h2 class="title">{{election.name}} &mdash; Compute Tally <span style="font-size:0.7em;">[<a href="{% url "helios.views.one_election_view" election.uuid %}">cancel</a>]</span></h2>

<p>
You are about to compute the tally for this election. You only will then see the results.
Expand Down
4 changes: 2 additions & 2 deletions helios/templates/election_audited_ballots.html
Expand Up @@ -3,7 +3,7 @@
{% block title %}Audited Ballots for {{election.name}}{% endblock %}

{% block content %}
<h2 class="title">{{election.name}} &mdash; Audited Ballots <span style="font-size:0.7em;">[<a href="{% url helios.views.one_election_view election_uuid=election.uuid %}">back to election</a>]</span></h2>
<h2 class="title">{{election.name}} &mdash; Audited Ballots <span style="font-size:0.7em;">[<a href="{% url "helios.views.one_election_view" election_uuid=election.uuid %}">back to election</a>]</span></h2>

<p>
When you prepare a ballot with Helios, you immediately receive a smart ballot tracker. Before you choose to cast that ballot, you have the option to ask Helios to "break open" that encrypted ballot and verify that Helios encrypted your ballot correctly. Once that's done, you can post that opened ballot here, on the audited ballots' list, for everyone to verify (your identity is not included). Once you've done this, you have to re-encrypt your choices and obtain a different smart ballot tracker. This helps reduce the chance that someone might coerce you to vote differently from your true choice.
Expand All @@ -14,7 +14,7 @@ <h2 class="title">{{election.name}} &mdash; Audited Ballots <span style="font-si
</p>

<p>
To verify an audited ballot, copy its entire content and paste it in the <a target="_new" href="/booth/single-ballot-verify.html?election_url={% url helios.views.one_election election.uuid %}">single ballot verifier</a>.
To verify an audited ballot, copy its entire content and paste it in the <a target="_new" href="/booth/single-ballot-verify.html?election_url={% url "helios.views.one_election" election.uuid %}">single ballot verifier</a>.
</p>

{% if audited_ballots %}
Expand Down
4 changes: 2 additions & 2 deletions helios/templates/election_bboard.html
Expand Up @@ -3,7 +3,7 @@
{% block title %}Ballot Tracking Center for {{election.name}}{% endblock %}

{% block content %}
<h2 class="title">{{election.name}} &mdash; Ballot Tracking Center <span style="font-size:0.7em;">[<a href="{% url helios.views.one_election_view election_uuid=election.uuid %}">back to election</a>]</span></h2>
<h2 class="title">{{election.name}} &mdash; Ballot Tracking Center <span style="font-size:0.7em;">[<a href="{% url "helios.views.one_election_view" election_uuid=election.uuid %}">back to election</a>]</span></h2>

<p>
This is the ballot tracking center, which displays the tracking numbers of all cast ballots in this election.
Expand Down Expand Up @@ -40,7 +40,7 @@ <h2 class="title">{{election.name}} &mdash; Ballot Tracking Center <span style="
{{voter.alias}}
{% else %}
<img border="0" height="20" src="/static/auth/login-icons/{{voter.voter_type}}.png" alt="{{voter.voter_type}}" /> {% if voter.name %}{{voter.name}}{% else %}{{voter.voter_id}}{% endif %}
{% endif %}</td><td><tt style="font-size: 1.4em;;">{% if voter.vote_hash %}{{voter.vote_hash}} <span style="font-size:0.8em;">[<a href="{% url helios.views.voter_last_vote election_uuid=election.uuid,voter_uuid=voter.uuid %}">view</a>]</span>{% else %}&mdash;{% endif %}</tt></td></tr>
{% endif %}</td><td><tt style="font-size: 1.4em;;">{% if voter.vote_hash %}{{voter.vote_hash}} <span style="font-size:0.8em;">[<a href="{% url "helios.views.voter_last_vote" election_uuid=election.uuid voter_uuid=voter.uuid %}">view</a>]</span>{% else %}&mdash;{% endif %}</tt></td></tr>
{% endfor %}
</table>

Expand Down
2 changes: 1 addition & 1 deletion helios/templates/election_build.html
@@ -1,7 +1,7 @@
{% extends "helios/templates/cryptobase.html" %}

{% block content %}
<h2 class="title">{{election.name}} &mdash; Questions <span style="font-size:0.7em;">[<a href="{% url helios.views.one_election_view election.uuid %}">back to election</a>]</span></h2>
<h2 class="title">{{election.name}} &mdash; Questions <span style="font-size:0.7em;">[<a href="{% url "helios.views.one_election_view" election.uuid %}">back to election</a>]</span></h2>

<script language="javascript">
{% if election.questions %}
Expand Down
2 changes: 1 addition & 1 deletion helios/templates/election_cast_confirm.html
Expand Up @@ -73,7 +73,7 @@ <h1>Sorry!<h1>
{% endif %}
</b><br /></p>
<p>
[<a href="{% url helios.views.one_election_view election.uuid %}">return to the main election page</a>]
[<a href="{% url "helios.views.one_election_view" election.uuid %}">return to the main election page</a>]
</p>
{% else %}
<p>
Expand Down
2 changes: 1 addition & 1 deletion helios/templates/election_edit.html
Expand Up @@ -2,7 +2,7 @@

{% block content %}

<h2 class="title">{{election.name}} &mdash; Update <span style="font-size:0.7em;">[<a href="{% url helios.views.one_election_view election.uuid %}">cancel</a>]</span></h2>
<h2 class="title">{{election.name}} &mdash; Update <span style="font-size:0.7em;">[<a href="{% url "helios.views.one_election_view" election.uuid %}">cancel</a>]</span></h2>

{% if error %}
<p style="color: red;">
Expand Down
2 changes: 1 addition & 1 deletion helios/templates/election_freeze.html
Expand Up @@ -29,7 +29,7 @@ <h2 class="title">{{election.name}} &mdash; Freeze Ballot</h2>
<li>{{issue.action}}</li>
{% endfor %}
</ul>
<a href="{% url helios.views.one_election_view election.uuid %}">go back to the election</a>
<a href="{% url "helios.views.one_election_view" election.uuid %}">go back to the election</a>
</p>
{% else %}
<form method="post" action="">
Expand Down
2 changes: 1 addition & 1 deletion helios/templates/election_keygenerator.html
Expand Up @@ -134,7 +134,7 @@ <h3>Your Secret Key</h3>
</p>
</div>

<form method="post" id="pk_form" action="{% url helios.views.trustee_upload_pk election.uuid, trustee.uuid %}">
<form method="post" id="pk_form" action="{% url "helios.views.trustee_upload_pk" election.uuid trustee.uuid %}">
<h3>Your Public Key</h3>
<p>
It's time to upload the public key to the server.
Expand Down
2 changes: 1 addition & 1 deletion helios/templates/election_new_2.html
Expand Up @@ -56,7 +56,7 @@ <h2 class="title">Create a New Election: {{name}}</h2>
<b>An election managed by multiple trustees</b>.
{% endifequal %}
{% endifequal %}
<form class="prettyform" action="{% url helios.views.election_new_3 %}" method="POST" id="create_election_form" onsubmit="return before_create();">
<form class="prettyform" action="{% url "helios.views.election_new_3" %}" method="POST" id="create_election_form" onsubmit="return before_create();">
<input type="hidden" name="csrf_token" value="{{csrf_token}}" />
<input type="hidden" name="name" value="{{name}}" />
<input type="hidden" name="public_key" id="pk" value="" />
Expand Down
2 changes: 1 addition & 1 deletion helios/templates/election_not_started.html
Expand Up @@ -9,6 +9,6 @@ <h2 class="title">Election {{election.name}} Not Yet Open</h2>
</p>

<p>
<a href="{% url helios.views.one_election_view election.uuid %}">back to the election</a>
<a href="{% url "helios.views.one_election_view" election.uuid %}">back to the election</a>
</p>
{% endblock %}
2 changes: 1 addition & 1 deletion helios/templates/election_questions.html
Expand Up @@ -2,7 +2,7 @@

{% block title %}Questions for {{election.name}}{% endblock %}
{% block content %}
<h3 class="title">{{election.name}} &mdash; Questions <span style="font-size:0.7em;">[<a href="{% url helios.views.one_election_view election.uuid %}">back to election</a>]</span></h3>
<h3 class="title">{{election.name}} &mdash; Questions <span style="font-size:0.7em;">[<a href="{% url "helios.views.one_election_view" election.uuid %}">back to election</a>]</span></h3>

<script language="javascript">
{% if election.questions %}
Expand Down
2 changes: 1 addition & 1 deletion helios/templates/election_register.html
Expand Up @@ -16,7 +16,7 @@ <h2 class="title">{{ election.name }} – Register</h2>
You are <em>not</em> registered for this election.
</p>

<form method="post" action="{% url helios.views.one_election_register election.uuid %}">
<form method="post" action="{% url "helios.views.one_election_register" election.uuid %}">
<input type="submit" value="register!" />
</form>
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion helios/templates/election_tallied.html
Expand Up @@ -9,6 +9,6 @@ <h2 class="title">Election {{election.name}} Already Tallied</h2>
</p>

<p>
<a href="{% url helios.views.one_election_view election.uuid %}">view the election tally</a>
<a href="{% url "helios.views.one_election_view" election.uuid %}">view the election tally</a>
</p>
{% endblock %}
34 changes: 17 additions & 17 deletions helios/templates/election_view.html
Expand Up @@ -5,7 +5,7 @@
<h3 class="title">{{ election.name }}
{% if admin_p %}
{% if not election.frozen_at %}
<small><a class="small button" href="{% url helios.views.one_election_edit election.uuid %}">edit</a></small>
<small><a class="small button" href="{% url "helios.views.one_election_edit" election.uuid %}">edit</a></small>
{% endif %}
{% endif %}</h3>
<p style="padding-top:0px; margin-top:0px">
Expand All @@ -14,20 +14,20 @@ <h3 class="title">{{ election.name }}
[archived]
{% endif %}
{% if admin_p %}
&nbsp;{% if election.is_archived %}<a class="small button" href="{% url helios.views.one_election_archive election_uuid=election.uuid %}?archive_p=0">unarchive it</a>{% else %}<a class="small button" href="{% url helios.views.one_election_archive election_uuid=election.uuid %}?archive_p=1">archive it</a>{% endif %}
&nbsp;{% if election.is_archived %}<a class="small button" href="{% url "helios.views.one_election_archive" election_uuid=election.uuid %}?archive_p=0">unarchive it</a>{% else %}<a class="small button" href="{% url "helios.views.one_election_archive" election_uuid=election.uuid %}?archive_p=1">archive it</a>{% endif %}
{% endif %}
<br />
{% if admin_p %}
{% if not election.private_p %}
{% if election.featured_p %}
this {{election.election_type}} is featured on the front page.
{% if can_feature_p %}
[<a href="{% url helios.views.one_election_set_featured election.uuid %}?featured_p=0">unfeature it</a>]
[<a href="{% url "helios.views.one_election_set_featured" election.uuid %}?featured_p=0">unfeature it</a>]
{% endif %}
{% else %}
this {{election.election_type}} is <u>not</u> featured on the front page.
{% if can_feature_p %}
[<a href="{% url helios.views.one_election_set_featured election.uuid %}?featured_p=1">feature it</a>]
[<a href="{% url "helios.views.one_election_set_featured" election.uuid %}?featured_p=1">feature it</a>]
{% endif %}
{% endif %}
{% endif %}
Expand All @@ -54,11 +54,11 @@ <h3 class="title">{{ election.name }}
{% endif %}

<p align="center" style="font-size: 1.5em;">
<a href="{% url helios.views.one_election_questions election.uuid %}">questions ({% if election.questions %}{{election.questions|length}}{% else %}0{% endif %})</a>
<a href="{% url "helios.views.one_election_questions" election.uuid %}">questions ({% if election.questions %}{{election.questions|length}}{% else %}0{% endif %})</a>
&nbsp;&nbsp;|&nbsp;&nbsp;
<a href="{% url helios.views.voters_list_pretty election.uuid %}">voters &amp; ballots</a>
<a href="{% url "helios.views.voters_list_pretty" election.uuid %}">voters &amp; ballots</a>
&nbsp;&nbsp;|&nbsp;&nbsp;
<a href="{% url helios.views.list_trustees_view election.uuid %}">trustees ({{trustees|length}})</a>
<a href="{% url "helios.views.list_trustees_view" election.uuid %}">trustees ({{trustees|length}})</a>
</p>

{% if admin_p %}
Expand Down Expand Up @@ -90,7 +90,7 @@ <h3 class="title">{{ election.name }}
{{issue.action}}{% if forloop.last %}{% else %}, and{% endif %}<br />
{% endfor %}
{% else %}
<a href="{% url helios.views.one_election_freeze election.uuid %}">freeze ballot and open election.</a>
<a href="{% url "helios.views.one_election_freeze" election.uuid %}">freeze ballot and open election.</a>
<br />
{% if election.voting_starts_at %}
once you do this, the election will be ready for voting and will open automatically<br />
Expand All @@ -107,20 +107,20 @@ <h3 class="title">{{ election.name }}
Tally computation is under way.<br />
Reload this page in a couple of minutes.
{% else %}
<a href="{% url helios.views.one_election_compute_tally election.uuid %}">compute encrypted tally</a><br />
<a href="{% url "helios.views.one_election_compute_tally" election.uuid %}">compute encrypted tally</a><br />
The encrypted votes will be combined into an encrypted tally. Once this is done,<br />
trustees will be asked to provide their share of the decryption.
{% endif %}
{% else %}

{% if election.result %}
<a href="{% url helios.views.release_result election.uuid %}">release result</a><br />
<a href="{% url "helios.views.release_result" election.uuid %}">release result</a><br />
The result displayed below is visible only to you.<br />
Once you release the result, it will be visible to everyone.
{% else %}

{% if election.ready_for_decryption_combination %}
<a href="{% url helios.views.combine_decryptions election.uuid %}">
<a href="{% url "helios.views.combine_decryptions" election.uuid %}">
{% if election.num_trustees == 1 %}
compute results
{% else %}
Expand All @@ -134,7 +134,7 @@ <h3 class="title">{{ election.name }}
Once you do this, the tally will visible to you, the administrator, only.
{% endif %}
{% else %}
<a href="{% url helios.views.list_trustees_view election.uuid %}">trustees (for decryption)</a>
<a href="{% url "helios.views.list_trustees_view" election.uuid %}">trustees (for decryption)</a>
{% endif %}

{% endif %}
Expand Down Expand Up @@ -239,7 +239,7 @@ <h3 class="highlight-box">Tally</h3>
{% if election.openreg %}
{% if election.eligibility %}
This election is open to: {{election.pretty_eligibility|safe}}
<a href="{{settings.SECURE_URL_HOST}}{% url helios_auth.views.index %}?return_url={{CURRENT_URL}}">Log in</a> to check your eligibility.
<a href="{{settings.SECURE_URL_HOST}}{% url "helios_auth.views.index" %}?return_url={{CURRENT_URL}}">Log in</a> to check your eligibility.
{% else %}
Anyone can vote in this election.
{% endif %}
Expand Down Expand Up @@ -271,22 +271,22 @@ <h3 class="highlight-box">Tally</h3>
{% endif %}

<p style="font-size: 1.3em;">
<a href="{% url helios.views.voters_list_pretty election.uuid %}">Ballot Tracking Center</a> &nbsp;| &nbsp;
<a href="{% url helios.views.one_election_audited_ballots election.uuid %}">Audited Ballots</a>
<a href="{% url "helios.views.voters_list_pretty" election.uuid %}">Ballot Tracking Center</a> &nbsp;| &nbsp;
<a href="{% url "helios.views.one_election_audited_ballots" election.uuid %}">Audited Ballots</a>
</p>

{% endif %}

{% if not election.voting_has_started %}
<p style="font-size: 1.2em;">
<a href="{{SECURE_URL_HOST}}/booth/vote.html?election_url={% url helios.views.one_election election.uuid %}">preview booth</a>
<a href="{{SECURE_URL_HOST}}/booth/vote.html?election_url={% url "helios.views.one_election" election.uuid %}">preview booth</a>
</p>
{% endif %}

{% if election.voting_has_stopped %}
<p style="font-size: 1.2em;">
{% if election.result %}
verify <a target="_blank" href="/verifier/verify.html?election_url={% url helios.views.one_election election.uuid %}">election tally</a>.
verify <a target="_blank" href="/verifier/verify.html?election_url={% url "helios.views.one_election" election.uuid %}">election tally</a>.
{% endif %}

review the <a href="{{vote_url}}">voting booth</a>.
Expand Down
2 changes: 1 addition & 1 deletion helios/templates/elections_administered.html
Expand Up @@ -5,7 +5,7 @@ <h2 class="title">Elections you Administer <span style="font-size:0.7em;">[<a hr

<ul>
{% for election in elections %}
<li> <a href="{% url helios.views.one_election_view election.uuid %}">{{election.name}}</a></li>
<li> <a href="{% url "helios.views.one_election_view" election.uuid %}">{{election.name}}</a></li>
{% endfor %}
</ul>
{% endblock %}
2 changes: 1 addition & 1 deletion helios/templates/elections_voted.html
Expand Up @@ -5,7 +5,7 @@ <h2 class="title">Elections where you voted <span style="font-size:0.7em;">[<a h

<ul>
{% for election in elections %}
<li> <a href="{% url helios.views.one_election_view election.uuid %}">{{election.name}}</a></li>
<li> <a href="{% url "helios.views.one_election_view" election.uuid %}">{{election.name}}</a></li>
{% endfor %}
</ul>
{% endblock %}

0 comments on commit b07c43d

Please sign in to comment.