Skip to content
Snippets Groups Projects
Unverified Commit 7463bab9 authored by RunasSudo's avatar RunasSudo
Browse files

Implement voting extension

parent 9a02136d
No related branches found
No related tags found
No related merge requests found
...@@ -18,6 +18,7 @@ urlpatterns = patterns('', ...@@ -18,6 +18,7 @@ urlpatterns = patterns('',
# edit election params # edit election params
(r'^/edit$', one_election_edit), (r'^/edit$', one_election_edit),
(r'^/schedule$', one_election_schedule), (r'^/schedule$', one_election_schedule),
(r'^/extend$', one_election_extend),
(r'^/archive$', one_election_archive), (r'^/archive$', one_election_archive),
# badge # badge
......
...@@ -29,6 +29,9 @@ class ElectionForm(forms.Form): ...@@ -29,6 +29,9 @@ class ElectionForm(forms.Form):
voting_ends_at = SplitDateTimeField(help_text = 'UTC date and time when voting ends', voting_ends_at = SplitDateTimeField(help_text = 'UTC date and time when voting ends',
widget=SplitSelectDateTimeWidget, required=False) widget=SplitSelectDateTimeWidget, required=False)
class ElectionTimeExtensionForm(forms.Form):
voting_extended_until = SplitDateTimeField(help_text = 'UTC date and time voting extended to',
widget=SplitSelectDateTimeWidget, required=False)
class EmailVotersForm(forms.Form): class EmailVotersForm(forms.Form):
subject = forms.CharField(max_length=80) subject = forms.CharField(max_length=80)
......
{% extends TEMPLATE_BASE %}
{% block content %}
<h2 class="title">{{election.name}} &mdash; Extend Voting <span style="font-size:0.7em;">[<a href="{% url "helios.views.one_election_view" election.uuid %}">cancel</a>]</span></h2>
<form class="prettyform" action="" method="POST" id="edit_election_form">
<input type="hidden" name="csrf_token" value="{{csrf_token}}" />
<table class="pretty">
{{election_form.as_table}}
</table>
<div>
<label for="">&nbsp;</label><input type="submit" value="Extend Voting" id="update_button" />
</div>
</form>
{% endblock %}
...@@ -247,6 +247,9 @@ Anyone can vote in this election. ...@@ -247,6 +247,9 @@ Anyone can vote in this election.
{% endif %} {% endif %}
{% if admin_p and election.voting_ends_at and not election.tallying_started_at %}
<br /><a href="{% url "helios.views.one_election_extend" election.uuid %}">extend voting</a><br />
{% endif %}
<div style="background: lightyellow; padding:5px; padding-left: 10px; margin-top: 15px; border: 1px solid #aaa; width: 720px;" class="round"> <div style="background: lightyellow; padding:5px; padding-left: 10px; margin-top: 15px; border: 1px solid #aaa; width: 720px;" class="round">
<a href="#" onclick="$('#auditbody').slideToggle(250);">Audit Info</a> <a href="#" onclick="$('#auditbody').slideToggle(250);">Audit Info</a>
......
...@@ -254,6 +254,23 @@ def one_election_edit(request, election): ...@@ -254,6 +254,23 @@ def one_election_edit(request, election):
def one_election_schedule(request, election): def one_election_schedule(request, election):
return HttpResponse("foo") return HttpResponse("foo")
@election_admin()
def one_election_extend(request, election):
if request.method == "GET":
election_form = forms.ElectionTimeExtensionForm({'voting_extended_until': election.voting_extended_until})
else:
check_csrf(request)
election_form = forms.ElectionTimeExtensionForm(request.POST)
if election_form.is_valid():
clean_data = election_form.cleaned_data
election.voting_extended_until = clean_data['voting_extended_until']
election.save()
return HttpResponseRedirect(settings.SECURE_URL_HOST + reverse(one_election_view, args=[election.uuid]))
return render_template(request, "election_extend", {'election_form' : election_form, 'election' : election})
@election_view() @election_view()
@return_json @return_json
def one_election(request, election): def one_election(request, election):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment