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

fixed a bug where election URL was not displayed, and made sure emailed link is direct to go vote

parent 3204a743
Branches
Tags
No related merge requests found
from django.conf import settings
from django.core.urlresolvers import reverse
from helios.views import election_shortcut
TEMPLATE_BASE = settings.HELIOS_TEMPLATE_BASE or "helios/templates/base.html"
......@@ -12,3 +14,4 @@ VOTERS_UPLOAD = settings.HELIOS_VOTERS_UPLOAD
# allow emailing of voters?
VOTERS_EMAIL = settings.HELIOS_VOTERS_EMAIL
......@@ -15,7 +15,7 @@ import datetime, logging, uuid, random
from crypto import electionalgs, algs, utils
from helios import utils as heliosutils
import helios
import helios.views
from helios import datatypes
......@@ -460,7 +460,7 @@ class Election(HeliosModel):
@property
def url(self):
return helios.get_election_url(self)
return helios.views.get_election_url(self)
def init_tally(self):
# FIXME: create the right kind of tally
......
......@@ -18,6 +18,7 @@ urlpatterns = patterns('',
# election shortcut by shortname
(r'^e/(?P<election_short_name>[^/]+)$', election_shortcut),
(r'^e/(?P<election_short_name>[^/]+)/vote$', election_vote_shortcut),
# vote shortcut
(r'^v/(?P<vote_tinyhash>[^/]+)$', castvote_shortcut),
......
......@@ -49,10 +49,12 @@ ELGAMAL_PARAMS_LD_OBJECT = datatypes.LDObject.instantiate(ELGAMAL_PARAMS, dataty
# single election server? Load the single electionfrom models import Election
from django.conf import settings
# a helper function
def get_election_url(election):
return settings.URL_HOST + reverse(election_shortcut, args=[election.short_name])
def get_election_govote_url(election):
return settings.URL_HOST + reverse(election_vote_shortcut, args=[election.short_name])
def get_castvote_url(cast_vote):
return settings.URL_HOST + reverse(castvote_shortcut, args=[cast_vote.vote_tinyhash])
......@@ -137,6 +139,17 @@ def election_shortcut(request, election_short_name):
else:
raise Http404
def election_vote_shortcut(request, election_short_name):
election = Election.get_by_short_name(election_short_name)
if election:
vote_url = "%s/booth/vote.html?%s" % (settings.SECURE_URL_HOST, urllib.urlencode({'election_url' : reverse(one_election, args=[election.uuid])}))
test_cookie_url = "%s?%s" % (reverse(test_cookie), urllib.urlencode({'continue_url' : vote_url}))
return HttpResponseRedirect(test_cookie_url)
else:
raise Http404
def castvote_shortcut(request, vote_tinyhash):
try:
cast_vote = CastVote.objects.get(vote_tinyhash = vote_tinyhash)
......@@ -1165,7 +1178,7 @@ def voters_email(request, election):
extra_vars = {
'custom_subject' : email_form.cleaned_data['subject'],
'custom_message' : email_form.cleaned_data['body'],
'election_url' : get_election_url(election),
'election_url' : get_election_govote_url(election),
'election' : election
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment