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
No related tags found
No related merge requests found
Subproject commit d7ed95619a63e1e5745f43427e9dbc0f8df0d028 Subproject commit ef0ee6f5e0fa2307f87998065fd0ff2aa6e29d07
...@@ -5,5 +5,6 @@ from views import * ...@@ -5,5 +5,6 @@ from views import *
urlpatterns = patterns('', urlpatterns = patterns('',
(r'^$', home), (r'^$', home),
(r'^about$', about) (r'^about$', about),
(r'^cast$', cast)
) )
...@@ -7,24 +7,40 @@ from auth.security import * ...@@ -7,24 +7,40 @@ from auth.security import *
from view_utils import * from view_utils import *
import helios.views import helios.views
import helios
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.http import HttpResponse, HttpResponseRedirect, Http404, HttpResponseNotAllowed from django.http import HttpResponse, HttpResponseRedirect, Http404, HttpResponseNotAllowed
def home(request): def home(request):
user = get_user(request) # create the election if need be
if user: election_params = {
elections = Election.get_by_user_as_admin(user) 'short_name' : 'iacr09',
elections_registered = Election.get_by_user_as_voter(user) 'name' : 'IACR 2009 Election',
else: 'description' : 'Election for the IACR Board - 2009',
elections = [] 'uuid' : 'iacr',
elections_registered = [] '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): def about(request):
return HttpResponse(request, "about") return HttpResponse(request, "about")
def election_shortcut(request, election_short_name): @helios.views.election_view(frozen=True)
election = Election.get_by_short_name(election_short_name) def cast(request, election):
return HttpResponseRedirect(reverse(helios.views.one_election_view, args=[election.uuid])) if request.method == "GET":
\ No newline at end of file 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 ...@@ -127,4 +127,4 @@ TEMPLATE_DEBUG = True
URL_HOST = "https://iacr-helios.appspot.com" URL_HOST = "https://iacr-helios.appspot.com"
IACR_ELECTION_UUID = '2d52d7fd-7d94-11de-b131-ed929ff4d68f' IACR_ELECTION_UUID = 'iacr'
\ No newline at end of file \ 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