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

Added auto election creation, with proper params

parent b843cabf
Branches
Tags
No related merge requests found
Subproject commit d7ed95619a63e1e5745f43427e9dbc0f8df0d028
Subproject commit ef0ee6f5e0fa2307f87998065fd0ff2aa6e29d07
......@@ -5,5 +5,6 @@ from views import *
urlpatterns = patterns('',
(r'^$', home),
(r'^about$', about)
(r'^about$', about),
(r'^cast$', cast)
)
......@@ -7,24 +7,40 @@ from auth.security import *
from view_utils import *
import helios.views
import helios
from django.core.urlresolvers import reverse
from django.http import HttpResponse, HttpResponseRedirect, Http404, HttpResponseNotAllowed
def home(request):
user = get_user(request)
if user:
elections = Election.get_by_user_as_admin(user)
elections_registered = Election.get_by_user_as_voter(user)
else:
elections = []
elections_registered = []
# create the election if need be
election_params = {
'short_name' : 'iacr09',
'name' : 'IACR 2009 Election',
'description' : 'Election for the IACR Board - 2009',
'uuid' : 'iacr',
'cast_url' : reverse(cast),
'self_registration' : False,
'openreg': False,
'admin' : helios.ADMIN
}
election = Election.get_by_key_name(election_params['short_name'])
if not election:
election = Election(key_name = election_params['short_name'], **election_params)
election.put()
return render_template(request, "index", {'elections' : elections, 'elections_registered' : elections_registered})
return render_template(request, "index")
def about(request):
return HttpResponse(request, "about")
def election_shortcut(request, election_short_name):
election = Election.get_by_short_name(election_short_name)
return HttpResponseRedirect(reverse(helios.views.one_election_view, args=[election.uuid]))
\ No newline at end of file
@helios.views.election_view(frozen=True)
def cast(request, election):
if request.method == "GET":
encrypted_vote = request.POST['encrypted_vote']
request.session['encrypted_vote'] = encrypted_vote
return render_template(request, "cast", {'election': election})
else:
# do the casting
pass
......@@ -127,4 +127,4 @@ TEMPLATE_DEBUG = True
URL_HOST = "https://iacr-helios.appspot.com"
IACR_ELECTION_UUID = '2d52d7fd-7d94-11de-b131-ed929ff4d68f'
\ No newline at end of file
IACR_ELECTION_UUID = 'iacr'
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment