Skip to content

Commit

Permalink
added ability to set an election_info_url, eg downloadable candidate …
Browse files Browse the repository at this point in the history
…bios, with a settings flag to enable this
  • Loading branch information
benadida committed Mar 2, 2014
1 parent 8333df8 commit 2724472
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions helios/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from models import Election
from widgets import *
from fields import *
from django.conf import settings


class ElectionForm(forms.Form):
short_name = forms.SlugField(max_length=25, help_text='no spaces, will be part of the URL for your election, e.g. my-club-2010')
Expand All @@ -18,6 +20,9 @@ class ElectionForm(forms.Form):
private_p = forms.BooleanField(required=False, initial=False, label="Private?", help_text='A private election is only visible to registered voters.')
help_email = forms.CharField(required=False, initial="", label="Help Email Address", help_text='An email address voters should contact if they need help.')

if settings.ALLOW_ELECTION_INFO_URL:
election_info_url = forms.CharField(required=False, initial="", label="Election Info Download URL", help_text="the URL of a PDF document that contains extra election information, e.g. candidate bios and statements")


class ElectionTimesForm(forms.Form):
# times
Expand Down
3 changes: 3 additions & 0 deletions helios/templates/election_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ <h3 class="title">{{ election.name }}
{{election.description}}
</div>

{% if election.election_info_url %}
<p style="font-size:1.5em;">[<a href="{{election.election_info_url}}">download election info</a>]</p>
{% 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>
Expand Down
3 changes: 3 additions & 0 deletions helios/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ def one_election_edit(request, election):
error = None
RELEVANT_FIELDS = ['short_name', 'name', 'description', 'use_voter_aliases', 'election_type', 'private_p', 'help_email', 'randomize_answer_order']
# RELEVANT_FIELDS += ['use_advanced_audit_features']

if settings.ALLOW_ELECTION_INFO_URL:
RELEVANT_FIELDS += ['election_info_url']

if request.method == "GET":
values = {}
Expand Down
2 changes: 1 addition & 1 deletion settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ def get_from_env(var, default):

# election stuff
SITE_TITLE = get_from_env('SITE_TITLE', 'Helios Voting')

MAIN_LOGO_URL = get_from_env('MAIN_LOGO_URL', '/static/logo.png')
ALLOW_ELECTION_INFO_URL = (get_from_env('ALLOW_ELECTION_INFO_URL', '0') == '1')

# FOOTER links
FOOTER_LINKS = json.loads(get_from_env('FOOTER_LINKS', '[]'))
Expand Down

0 comments on commit 2724472

Please sign in to comment.