Initial commit of DEMOS2 with the upgraded 'Create Event' UI. However, there is no input validation currently

This commit is contained in:
vince0656 2018-06-12 13:31:38 +01:00
commit 7084bd1b16
155 changed files with 8102 additions and 0 deletions

View file

@ -0,0 +1,429 @@
{% extends "bases/bootstrap-with-nav.html" %}
{% load staticfiles %}
{% load bootstrap3 %}
{% block content %}
<!-- The following UI was ported from the Election Authority UI in DEMOS1 by Vincent de Almeida -->
<!-- The DEMOS1 repository can be found at: https://github.com/mlevogiannis/demos-voting -->
<!-- TODO: look into i18n translations as this was a feature implemented in DEMOS1 -->
<hr/>
<div class="container">
<div class="page-header">
<h2>Create New Event with Polls</h2>
</div>
<div class="row">
<div class="col-xs-12">
<form id="election-form" class="form-horizontal" method="POST" novalidate>
{% csrf_token %}
<!-- TODO: Have not imported the if form not valid template code as this needs further investigating -->
<!-- Name -->
<div class="form-group"> <!-- Excluded class(missing %s): { if election_form.name.errors }has-error{ endif } -->
<label for="name-input" class="col-sm-3 col-md-2 control-label">Name:</label> <!-- This text can be a template variable -->
<div class="col-sm-9 col-md-10">
<input type="text" class="form-control" id="name-input" placeholder="Example: My poll" name="name-input" maxlength="255">
<span id="name-input-help-block" class="help-block">
<!-- Error handling / input validation has been removed temporarily and would be placed here -->
A short and clear name.
<!-- TODO: Alignment is potentially slightly too much to the left -->
</span>
</div>
</div>
<!-- Slug / Identifier -->
<div class="form-group"> <!-- Excluded class(missing %s): { if election_form.slug.errors }has-error{ endif } -->
<label for="identifier-input" class="col-sm-3 col-md-2 control-label">Identifier:</label> <!-- This text can be a template variable -->
<div class="col-sm-9 col-md-10">
<input type="text" class="form-control" id="identifier-input" placeholder="Example: My-poll" name="identifier-input" maxlength="255">
<span id="identifier-input-help-block" class="help-block">
<!-- Error handling / input validation has been removed temporarily and would be placed here -->
Used in the election URL, it must only consist of letters, numbers, underscores or hyphens; no whitespace is permitted.
<!-- TODO: Alignment is potentially slightly too much to the left -->
</span>
</div>
</div>
<!-- Voting start time -->
<div class="form-group "> <!-- Excluded class(missing %s): { if election_form.voting_starts_at.errors }has-error{ endif } -->
<label for="vote-start-input" class="col-sm-3 col-md-2 control-label">Voting starts at:</label>
<div class="col-sm-9 col-md-10">
<div class="input-group date">
<input type="text" class="form-control" data-date-format="YYYY-MM-DD H:mm" id="vote-start-input" name="vote-start-input">
<span class="input-group-addon btn">
<i class="fa fa-calendar" aria-hidden="true"></i>
/
<i class="fa fa-clock-o" aria-hidden="true"></i>
</span>
</div>
<span id="vote-start-input-help-block" class="help-block">
<!-- Error handling / input validation has been removed temporarily and would be placed here -->
Date and time when registered voters can commence voting.
</span>
</div>
</div>
<!-- Voting end time -->
<div class="form-group "> <!-- Excluded class(missing %s): { if election_form.voting_ends_at.errors }has-error{ endif } -->
<label for="vote-end-input" class="col-sm-3 col-md-2 control-label">Voting ends at:</label>
<div class="col-sm-9 col-md-10">
<div class="input-group date">
<input type="text" class="form-control" data-date-format="YYYY-MM-DD H:mm" id="vote-end-input" name="vote-end-input">
<span class="input-group-addon btn">
<i class="fa fa-calendar" aria-hidden="true"></i>
/
<i class="fa fa-clock-o" aria-hidden="true"></i>
</span>
</div>
<span id="vote-end-input-help-block" class="help-block">
<!-- Error handling / input validation has been removed temporarily and would be placed here -->
Date and time when registered voters can no longer vote.
</span>
</div>
</div>
<!-- Question / Statement -->
<div class="form-group">
<label for="question-input" class="col-sm-3 col-md-2 control-label">Question / Statement:</label> <!-- This text can be a template variable -->
<div class="col-sm-9 col-md-10">
<input type="text" class="form-control" id="question-input" placeholder="Example: Elections for the European Parliament" name="question-input" maxlength="200">
<span id="question-input-help-block" class="help-block">
<!-- Error handling / input validation has been removed temporarily and would be placed here -->
Question / Statement that will be put forward to voters along with the below options.
<!-- TODO: Alignment is potentially slightly too much to the left -->
</span>
</div>
</div>
<!-- Options -->
<div class="form-group">
<label for="options-input" class="col-sm-3 col-md-2 control-label">Options:</label> <!-- This text can be a template variable -->
<div class="col-sm-9 col-md-10">
<div class="form-group"> <!-- Excluded class(missing %s): { if option_formset.non_form_errors }has-error{ endif }-->
<table id="options-input-table" class="table table-hover">
<thead>
<tr>
<th class="text-center">#</th>
<th>Option</th>
<th class="text-center">Actions</th>
<!--Not sure what this does so disabling it: <th class="hidden">{ option_formset.management_form }</th> -->
</tr>
</thead>
<tbody id="sort" class="formset option-formset" data-formset-prefix="questions" data-formset-type="inline">
<!-- Option -->
<tr class="formset-form sorting-row" data-formset-form-prefix="question">
<!-- # -->
<th class="formset-form-index text-center" scope=row>
1
</th>
<!-- Option Label -->
<td>
<div> <!-- Has error conditional class removed -->
<!-- TODO: Add an invisible screen reader label to associate with this and other inputs -->
<input type="text" class="form-control input-sm" placeholder="Example: Candidate 1" id="option-name-input" name="option-name-input" maxlength="200">
<!-- Error handling / input validation has been removed temporarily and would be placed here -->
</div>
</td>
<!-- Delete Action -->
<td class="formset-form-actions text-center">
<button type="button" class="btn btn-sm btn-default formset-form-remove" aria-label="Remove">
<i class="fa fa-trash-o" aria-hidden="true"></i>
</button>
</td>
</tr>
<!-- Option -->
<tr class="formset-form sorting-row" data-formset-form-prefix="question">
<!-- # -->
<th class="formset-form-index text-center" scope=row>
2
</th>
<!-- Option Label -->
<td>
<div> <!-- Has error conditional class removed -->
<!-- TODO: Add an invisible screen reader label to associate with this and other inputs -->
<input type="text" class="form-control input-sm" placeholder="Example: Candidate 2" id="option-name-input" name="option-name-input" maxlength="200">
<!-- Error handling / input validation has been removed temporarily and would be placed here -->
</div>
</td>
<!-- Delete Action -->
<td class="formset-form-actions text-center">
<button type="button" class="btn btn-sm btn-default formset-form-remove" aria-label="Remove">
<i class="fa fa-trash-o" aria-hidden="true"></i>
</button>
</td>
</tr>
<!-- Option -->
<tr class="formset-form sorting-row formset-form-empty hidden" data-formset-form-prefix="question">
<!-- # -->
<th class="formset-form-index text-center" scope=row>
X
</th>
<!-- Option Label -->
<td>
<div> <!-- Has error conditional class removed -->
<!-- TODO: Add an invisible screen reader label to associate with this and other inputs -->
<input type="text" class="form-control input-sm" placeholder="Example: Candidate X" id="option-name-input" name="option-name-input" maxlength="200">
<!-- Error handling / input validation has been removed temporarily and would be placed here -->
</div>
</td>
<!-- Delete Action -->
<td class="formset-form-actions text-center">
<button type="button" class="btn btn-sm btn-default formset-form-remove" aria-label="Remove">
<i class="fa fa-trash-o" aria-hidden="true"></i>
</button>
</td>
</tr>
</tbody>
</table>
<div class="clearfix">
<button type="button" class="btn btn-primary formset-add" data-formset-prefix="questions">
<i class="fa fa-plus-circle" aria-hidden="true"></i>
Add Question Option
</button>
</div>
<span id="question-input-help-block" class="help-block">
<!-- Error handling / input validation has been removed temporarily and would be placed here -->
Drag and drop to re-order options.
</span>
</div>
</div>
</div>
<!-- Number of option selections -->
<div class="form-group">
<label for="selections-input" class="col-sm-3 col-md-2 control-label">Number of Selections:</label> <!-- This text can be a template variable -->
<div class="col-sm-9 col-md-10">
<div class="row">
<div class="col-xs-6">
<label class="sr-only" for="minimum-input">Minimum</label>
<input type="number" class="form-control" id="minimum-input" placeholder="Minimum" value="" name="minimum-input" min="0"> <!-- TODO: Max should be set to the number of options -->
<!-- Error handling / input validation has been removed temporarily and would be placed here -->
</div>
<div class="col-xs-6">
<label class="sr-only" for="maximum-input">Maximum</label>
<input type="number" class="form-control" id="maximum-input" placeholder="Maximum" value="" name="maximum-input" min="1"> <!-- TODO: Max should be set to the number of options -->
<!-- Error handling / input validation has been removed temporarily and would be placed here -->
</div>
</div>
<span id="question-input-help-block" class="help-block">
<!-- Error handling / input validation has been removed temporarily and would be placed here -->
Minimum and maximum number of option selections that a voter can make for the specified question / statement.
<!-- TODO: Alignment is potentially slightly too much to the left -->
</span>
</div>
</div>
<!-- Organisers -->
<div class="form-group">
<label for="organisers-input" class="col-sm-3 col-md-2 control-label">Organisers:</label> <!-- This text can be a template variable -->
<div class="col-sm-9 col-md-10">
<div class="form-group">
<table id="organisers-input-table" class="table table-hover">
<thead>
<tr>
<th class="text-center">#</th>
<th>Email</th>
<th class="text-center">Actions</th>
<!--Not sure what this does so disabling it: <th class="hidden">{ option_formset.management_form }</th> -->
</tr>
</thead>
<tbody class="formset organiser-formset" data-formset-prefix="organisers" data-formset-type="inline">
<!-- Organiser -->
<tr class="formset-form sorting-row" data-formset-form-prefix="organiser">
<th class="formset-form-index text-center" scope=row>
<!-- # -->
1
</th>
<td>
<!-- Email -->
<div> <!-- Has error conditional class removed -->
<!-- TODO: Add an invisible screen reader label to associate with this and other inputs -->
<input type="text" class="form-control input-sm" placeholder="Example: organiser@example.com" id="organiser-email-input" name="organiser-email-input" value="{{ user_email }}" maxlength="255">
<!-- Error handling / input validation has been removed temporarily and would be placed here -->
</div>
</td>
<td class="formset-form-actions text-center">
<!-- Action -->
<button type="button" class="btn btn-sm btn-default formset-form-remove" aria-label="Remove">
<i class="fa fa-trash-o" aria-hidden="true"></i>
</button>
</td>
</tr>
<!-- Organiser -->
<tr class="formset-form sorting-row" data-formset-form-prefix="question">
<th class="formset-form-index text-center" scope=row>
<!-- # -->
2
</th>
<td>
<!-- Email -->
<div> <!-- Has error conditional class removed -->
<!-- TODO: Add an invisible screen reader label to associate with this and other inputs -->
<input type="text" class="form-control input-sm" placeholder="Example: organiser@example.com" id="organiser-email-input" name="organiser-email-input" maxlength="255">
<!-- Error handling / input validation has been removed temporarily and would be placed here -->
</div>
</td>
<td class="formset-form-actions text-center">
<button type="button" class="btn btn-sm btn-default formset-form-remove" aria-label="Remove">
<i class="fa fa-trash-o" aria-hidden="true"></i>
</button>
</td>
</tr>
<!-- Organiser -->
<tr class="formset-form sorting-row formset-form-empty hidden" data-formset-form-prefix="question">
<th class="formset-form-index text-center" scope=row>
<!-- # -->
X
</th>
<td>
<!-- Email -->
<div> <!-- Has error conditional class removed -->
<!-- TODO: Add an invisible screen reader label to associate with this and other inputs -->
<input type="text" class="form-control input-sm" placeholder="Example: organiser@example.com" id="organiser-email-input" name="organiser-email-input" maxlength="255">
<!-- Error handling / input validation has been removed temporarily and would be placed here -->
</div>
</td>
<td class="formset-form-actions text-center">
<button type="button" class="btn btn-sm btn-default formset-form-remove" aria-label="Remove">
<i class="fa fa-trash-o" aria-hidden="true"></i>
</button>
</td>
</tr>
</tbody>
</table>
<div class="clearfix">
<button type="button" class="btn btn-primary formset-add" data-formset-prefix="organisers">
<i class="fa fa-plus-circle" aria-hidden="true"></i>
Add Organiser Email
</button>
</div>
<span id="question-input-help-block" class="help-block">
<!-- Error handling / input validation has been removed temporarily and would be placed here -->
Drag and drop to re-order emails.
</span>
</div>
</div>
</div>
<!-- Trustees -->
<div class="form-group">
<label for="trustees-input" class="col-sm-3 col-md-2 control-label">Trustees:</label> <!-- This text can be a template variable -->
<div class="col-sm-9 col-md-10">
<div class="form-group">
<table id="trustees-input-table" class="table table-hover">
<thead>
<tr>
<th class="text-center">#</th>
<th>Email</th>
<th class="text-center">Actions</th>
<!--Not sure what this does so disabling it: <th class="hidden">{ option_formset.management_form }</th> -->
</tr>
</thead>
<tbody class="formset trustee-formset" data-formset-prefix="trustees" data-formset-type="inline">
<!-- Trustee -->
<tr class="formset-form sorting-row" data-formset-form-prefix="trustee">
<th class="formset-form-index text-center" scope=row>
<!-- # -->
1
</th>
<td>
<!-- Email -->
<div> <!-- Has error conditional class removed -->
<!-- TODO: Add an invisible screen reader label to associate with this and other inputs -->
<input type="text" class="form-control input-sm" placeholder="Example: trustee@example.com" id="trustee-email-input" name="trustee-email-input" value="{{ user_email }}" maxlength="255">
<!-- Error handling / input validation has been removed temporarily and would be placed here -->
</div>
</td>
<td class="formset-form-actions text-center">
<!-- Action -->
<button type="button" class="btn btn-sm btn-default formset-form-remove" aria-label="Remove">
<i class="fa fa-trash-o" aria-hidden="true"></i>
</button>
</td>
</tr>
<!-- Trustee -->
<tr class="formset-form sorting-row" data-formset-form-prefix="trustee">
<th class="formset-form-index text-center" scope=row>
<!-- # -->
2
</th>
<td>
<!-- Email -->
<div> <!-- Has error conditional class removed -->
<!-- TODO: Add an invisible screen reader label to associate with this and other inputs -->
<input type="text" class="form-control input-sm" placeholder="Example: trustee@example.com" id="trustee-email-input" name="trustee-email-input" maxlength="255">
<!-- Error handling / input validation has been removed temporarily and would be placed here -->
</div>
</td>
<td class="formset-form-actions text-center">
<button type="button" class="btn btn-sm btn-default formset-form-remove" aria-label="Remove">
<i class="fa fa-trash-o" aria-hidden="true"></i>
</button>
</td>
</tr>
<!-- Trustee -->
<tr class="formset-form sorting-row formset-form-empty hidden" data-formset-form-prefix="trustee">
<th class="formset-form-index text-center" scope=row>
<!-- # -->
X
</th>
<td>
<!-- Email -->
<div> <!-- Has error conditional class removed -->
<!-- TODO: Add an invisible screen reader label to associate with this and other inputs -->
<input type="text" class="form-control input-sm" placeholder="Example: trustee@example.com" id="trustee-email-input" name="trustee-email-input" maxlength="255">
<!-- Error handling / input validation has been removed temporarily and would be placed here -->
</div>
</td>
<td class="formset-form-actions text-center">
<button type="button" class="btn btn-sm btn-default formset-form-remove" aria-label="Remove">
<i class="fa fa-trash-o" aria-hidden="true"></i>
</button>
</td>
</tr>
</tbody>
</table>
<div class="clearfix">
<button type="button" class="btn btn-primary formset-add" data-formset-prefix="trustees">
<i class="fa fa-plus-circle" aria-hidden="true"></i>
Add Trustee Email
</button>
</div>
<span id="question-input-help-block" class="help-block">
<!-- Error handling / input validation has been removed temporarily and would be placed here -->
Drag and drop to re-order emails.
</span>
</div>
</div>
</div>
<!-- Voters List -->
<div class="form-group">
<label for="voters-list-input" class="col-sm-3 col-md-2 control-label">Voters List:</label> <!-- This text can be a template variable -->
<div class="col-sm-9 col-md-10">
<textarea class="form-control" id="voters-list-input" placeholder="alice@example.com, bob@example.com..." name="voters-list-input" rows="4"></textarea>
<span id="voters-list-input-help-block" class="help-block">
<!-- Error handling / input validation has been removed temporarily and would be placed here -->
Manually enter email addresses separated with commas. Alternatively, you can also upload a CSV file:
<!-- TODO: Alignment is potentially slightly too much to the left -->
</span>
<label for="files" class="btn btn-primary">
Upload CSV
</label>
<input type="file" id="files" name="file" class="btn-info">
<h4 id="result" class="hidden"></h4>
</div>
</div>
<!-- reCAPTCHA -->
<div class="form-group">
<label for="recaptcha-input" class="col-sm-3 col-md-2 control-label">reCAPTCHA:</label> <!-- This text can be a template variable -->
<div class="col-sm-9 col-md-10">
<div class="g-recaptcha" data-callback="recaptchaCallback" data-sitekey="{{ G_R_SITE_KEY }}"></div> <!-- Need to finish server implementation and import key from settings -->
<span id="recaptcha-input-help-block" class="help-block">
<!-- Error handling / input validation has been removed temporarily and would be placed here -->
Tick the box to prove that you're not a robot.
<!-- TODO: Alignment is potentially slightly too much to the left -->
</span>
</div>
</div>
<hr>
<input class="btn btn-success" type="submit" value="Create Event" id="submit-event-create" disabled/>
<input class="btn btn-danger" type="button" value="Cancel" onclick="location.href='{% url 'polls:index' %}'" />
</form>
</div>
</div>
</div>
{% endblock %}

View file

@ -0,0 +1,6 @@
{% load crispy_forms_tags %}
<div class="formset">
{% crispy formset helper %}
<button type="button" class="btn btn-default add-another-btn" name="add" value="Add another">Add</button>
</div>

View file

@ -0,0 +1,17 @@
{% extends "bases/bootstrap-with-nav.html" %}
{% load staticfiles %}
{% load bootstrap3 %}
{% block content %}
<div class="container">
<h1>Create Poll for {{event.title}}</h1>
{% load crispy_forms_tags %}
<form method="post" action="" class="">
{% crispy question_form %}
<input class="btn btn-default" type="submit" value="Submit"/>
</form>
</div>
{% endblock %}

View file

@ -0,0 +1,21 @@
{% extends "bases/bootstrap-with-nav.html" %}
{% load staticfiles %}
{% block content %}
<div class="container">
<h1>{{ question.question_text }}</h1>
{% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}
<form action="{% url 'polls:vote' question.id %}" method="post">
{% csrf_token %}
{% for choice in question.choice_set.all %}
<input type="radio" name="choice" id="choice{{ forloop.counter }}" value="{{ choice.id }}" />
<label for="choice{{ forloop.counter }}">{{ choice.choice_text }}</label><br />
{% endfor %}
<input type="submit" value="Vote" />
</form>
</div>
{% endblock %}

View file

@ -0,0 +1,32 @@
{% extends "bases/bootstrap-with-nav.html" %}
{% load staticfiles %}
{% load bootstrap3 %}
{% comment %} is it safe really? {% endcomment %}
{% block sk-file-name %}{{ event.title|safe }}{% endblock %}
{% block content %}
<div class="container">
<h1>Event: {{event.title}}</h1>
<h2>Trustee Decrypt</h2>
<div class="panel panel-default">
<div class="panel-heading">Secret Key</div>
<div class="panel panel-body">
<input id="secret-key" class="textinput textInput form-control" type="text"></input>
<p>Use your secret key to generate a decrypted cipher</p>
<button id="keygen-btn" onclick="demosEncrypt.decryptCipher()" class="btn btn-default">Decrypt</button>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">Encrypted Ciphers</div>
<div class="panel panel-body">
{% load crispy_forms_tags %}
<form method="post" action="" class="">
{% crispy formset helper %}
<input class="btn btn-default" type="submit" value="Submit" disabled>
</form>
</div>
</div>
</div>
{% endblock %}

View file

@ -0,0 +1,39 @@
{% extends "bases/bootstrap-with-nav.html" %}
{% load staticfiles %}
{% load bootstrap3 %}
{% block content %}
<div class="container">
<a href="{% url 'polls:index' %}"><< Back to Events List</a>
<br/>
<h1>Event: {{object.title}}</h1>
<p>By {{object.users_organisers.all}}</p>
<ul class="nav nav-tabs">
<li class="{% block event_nav_details %}{% endblock %}">
<a href="{% url 'polls:view-event' event.id %}">Details</a>
</li>
<li class="{% block event_nav_polls %}{% endblock %}">
<a href="{% url 'polls:event-polls' event.id %}">Polls</a>
</li>
<li class="{% block event_nav_organisers %}{% endblock %}">
<a href="{% url 'polls:event-organisers' event.id %}">Organisers</a>
</li>
{% if event.prepared == False and is_trustee %}
<li class="">
<a href="{% url 'polls:prepare-event' event.id %}">Prepare Event</a>
</li>
{% endif %}
{% if is_organiser %}
<li class="">
<a href="{% url 'polls:edit-event' event.id %}"><span class="fa fa-pencil"></span> Edit Event</a>
</li>
<li class="{% block event_nav_launch %}{% endblock %}">
<a href="{% url 'polls:launch-event' event.id %}">Launch Event</a>
</li>
{% endif %}
</ul>
{% block event_content %}{% endblock %}
</div>
{% endblock %}

View file

@ -0,0 +1,13 @@
{% extends "polls/event_detail_base.html" %}
{% load staticfiles %}
{% load bootstrap3 %}
{% block event_nav_details %}active{% endblock %}
{% block event_content %}
<h2>Event Details</h2>
<span>Ready/Prepared: {{ event.prepared }}</span>
<br />
<span>Start Time: {{ event.start_time }}</span>
<br />
<span>End Time: {{ event.end_time }}</span>
{% endblock %}

View file

@ -0,0 +1,14 @@
{% extends "polls/event_detail_base.html" %}
{% load staticfiles %}
{% load bootstrap3 %}
{% block event_nav_launch %}active{% endblock %}
{% block event_content %}
<h2>Event Details</h2>
<span>Trustee keys: {{ event.trustee_keys.count }} / {{ event.users_trustees.count }}</span>
<br />
<span>EID (param): {{ event.EID }} </span>
<br />
<span>Public key: {{ event.public_key }} </span>
{% endblock %}

View file

@ -0,0 +1,37 @@
{% extends "polls/event_detail_base.html" %}
{% load staticfiles %}
{% load bootstrap3 %}
{% block event_nav_organisers %}active{% endblock %}
{% block event_content %}
<h2>Event Organisers</h2>
{% if object.users_organisers.all %}
<ul class="list-group">
{% for user in object.users_organisers.all %}
<li class="list-group-item">{{ user.email }}</li>
{% endfor %}
</ul>
{% else %}
<p>No organisers for this Event.</p>
{% endif %}
<h2>Event Trustees</h2>
{% if object.users_trustees.all %}
<ul class="list-group">
{% for user in object.users_trustees.all %}
<li class="list-group-item">{{ user.email }}</li>
{% endfor %}
</ul>
{% else %}
<p>No trustees for this Event.</p>
{% endif %}
<h2>Voters</h2>
{% if object.voters.all %}
<ul class="list-group">
{% for voter in object.voters.all %}
<li class="list-group-item">{{ voter.email }}</li>
{% endfor %}
</ul>
{% else %}
<p>No voters for this Event.</p>
{% endif %}
{% endblock %}

View file

@ -0,0 +1,20 @@
{% extends "polls/event_detail_base.html" %}
{% load staticfiles %}
{% load bootstrap3 %}
{% block event_nav_polls %}active{% endblock %}
{% block event_content %}
<h2>Related Polls</h2>
{% if object.polls.all %}
<ul class="list-group">
{% for poll in object.polls.all %}
<li class="list-group-item"><a href="{% url 'polls:view-poll' event_id=event.id poll_num=forloop.counter %}">{{ poll.question_text }}</a></li>
{% endfor %}
</ul>
{% else %}
<p>No polls are available for this Event.</p>
{% endif %}
{% if is_organiser %}
<a href="{% url 'polls:create-poll' event.id %}" class="btn btn-default" role="button">Add Poll</a>
{% endif %}
{% endblock %}

View file

@ -0,0 +1,57 @@
{% extends "bases/bootstrap-with-nav.html" %}
{% load staticfiles %}
{% block content %}
<div class="container">
<div class="form-group">
<!-- Heading -->
<div class="col-xs-5 col-sm-3 col-md-2">
<h1>Events</h1>
</div>
<!-- Create Button -->
<div class="col-xs-7 col-sm-9 col-md-10 marginTopCreateButton">
<a href="{% url 'polls:create-event' %}" class="btn btn-primary" style="float:right">
<span class="glyphicon glyphicon-plus"></span> Create New
</a>
</div>
</div>
{% if object_list %}
<div class="form-group">
<table id="trustees-input-table" class="table table-hover marginTopEventList">
<thead>
<tr>
<th class="text-center">Event</th>
<th class="text-center">Start Time</th>
<th class="text-center">End Time</th>
<th class="text-center">No. Polls</th>
<th class="text-center">Edit</th>
<!-- Could also add a delete column to easily remove an event -->
</tr>
</thead>
<tbody>
{% for event in object_list %}
<tr>
<td class="text-center"><a href="{% url 'polls:view-event' event.id %}">{{ event.title }}</a></td>
<td class="text-center">{{ event.start_time }}</td>
<td class="text-center">{{ event.end_time }}</td>
<td class="text-center">{{ event.polls.count }}</td>
<td class="text-center">
<a href="{% url 'polls:edit-event' event.id %}">
<span class="btn btn-default glyphicon glyphicon-pencil"></span>
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="col-xs-12 col-sm-12 col-md-12">
<h4>There are currently no events.</h4>
</div>
{% endif %}
</div>
{% endblock %}

View file

@ -0,0 +1,34 @@
{% extends "bases/bootstrap-with-nav.html" %}
{% load staticfiles %}
{% load bootstrap3 %}
{% comment %} is it safe really? {% endcomment %}
{% block sk-file-name %}{{ event.title|safe }}{% endblock %}
{% block content %}
<div class="container">
<h1>Event: {{event.title}}</h1>
<h2>Trustee Setup</h2>
<div class="panel panel-default">
<div class="panel-heading">Public Key</div>
<div class="panel panel-body">
{% load crispy_forms_tags %}
<form method="post" action="" class="">
{% crispy form %}
<input id="public-submit" class="btn btn-default" type="submit" value="Submit" disabled="true"/>
</form>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">Secret Key</div>
<div class="panel panel-body">
<input id="secret-key" class="textinput textInput form-control" type="text"></input>
<input id="event-param" type="text" value="{{event.EID}}" hidden></input>
<p>Make a backup of this secret key before submitting your public key. This can NOT be recalculated if forgotten!</p>
<button id="keygen-btn" onclick="demosEncrypt.generateKeys()" class="btn btn-default">Generate</button>
<a id="download-btn" role="button" href="#" class="btn btn-default" disabled>Download</a>
</div>
</div>
</div>
{% endblock %}

View file

@ -0,0 +1,16 @@
{% extends "bases/bootstrap-with-nav.html" %}
{% load staticfiles %}
{% load bootstrap3 %}
{% block content %}
<div class="container">
<h1>{{ form_title }}</h1>
{% load crispy_forms_tags %}
<form method="post" action="" {{ form_attributes }} class="">
{% crispy form %}
<input class="btn btn-default" type="submit" value="Submit"/>
</form>
</div>
{% endblock %}

View file

@ -0,0 +1,85 @@
{% extends "bases/bootstrap-with-nav.html" %}
{% load staticfiles %}
{% load bootstrap3 %}
{% block app_js_vars %}
var option_count = {{ object.options.count }};
{% endblock %}
{% block content %}
<div class="container">
<input id="event-param" type="text" value="{{event.EID}}" hidden></input>
<input id="comb_pk" type="text" value="{{event.public_key}}" hidden></input>
<h1>Poll: {{object.question_text}}</h1>
<span>Poll {{ poll_num }} of {{ poll_count }} in Event: <a href="{% url 'polls:view-event' object.event.id %}">{{ object.event.title }}</a></span>
<div class="panel panel-body">
{% if prev_index %}
<a href="{% url 'polls:view-poll' event_id=object.event.id poll_num=prev_index %}" class="btn" role="button">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
</a>
{% endif %}
{% if next_index %}
<a href="{% url 'polls:view-poll' event_id=object.event.id poll_num=next_index %}" class="btn" role="button">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
</a>
{% endif %}
</div>
<a href="{% url 'polls:edit-poll' event_id=object.event.id poll_num=poll_num %}"><span class="fa fa-pencil"></span> Edit Poll</a>
{% if object.options.all %}
<h3>Options</h3>
<p> {{ vote_count }} vote(s) have been cast</p>
{% if can_vote %}
{% if has_voted %}
<p>You have already voted in this poll. Resubmitting the form will change your vote.</p>
{% endif %}
<p>Voting as {{ voter_email }} -- Do NOT share this url</p>
{% load crispy_forms_tags %}
<div class="panel panel-default">
<div class="panel-heading">Options</div>
<div class="panel panel-body">
<select class="radio-inline select form-control" id="poll-options" name="options">
{% load custom_filters_tags %}
{% for option in object.options.all %}
<option value="{{forloop.counter|get_ballot_value}}">{{ option.choice_text }}</option>
{% endfor %}
</select>
<button id="keygen-btn" onclick="demosEncrypt.encryptAndSubmit()" class="btn btn-default">Encrypt & Submit</button>
<form id="cipher-form" method="post" action="" class="">
{% crispy form %}
{% csrf_token %}
</form>
</div>
</div>
{% else %}
<div class="alert alert-warning" role="alert">
<p>You do not have permission to vote in this Event.</p>
</div>
{% endif %}
{% else %}
<p>No options are available.</p>
{% endif %}
</div>
<br>
<br>
POLL ENC {{ object.enc }}
{% if form.errors %}
{% for field in form %}
{% for error in field.errors %}
<div class="alert alert-danger">
<strong>{{ error|escape }}</strong>
</div>
{% endfor %}
{% endfor %}
{% for error in form.non_field_errors %}
<div class="alert alert-danger">
<strong>{{ error|escape }}</strong>
</div>
{% endfor %}
{% endif %}
{% endblock %}

View file

@ -0,0 +1,21 @@
{% extends "bases/bootstrap-with-nav.html" %}
{% load staticfiles %}
{% block content %}
<div class="container">
<h1>{{ question.question_text }}</h1>
<ul>
{% for choice in question.choice_set.all %}
<li class="list-group-item">{{ choice.choice_text }} <span class="badge">{{ choice.votes }} vote{{ choice.votes|pluralize }}</span></li>
{% endfor %}
</ul>
<a href="{% url 'polls:detail' question.id %}">Vote again?</a>
</div>
{% endblock %}

View file

@ -0,0 +1,21 @@
{% extends "bases/bootstrap-with-nav.html" %}
{% load staticfiles %}
{% load bootstrap3 %}
{% block content %}
<div class="container">
<h1>Poll: {{poll.question_text}}</h1>
{% if poll.options %}
<ul class="list-group">
{% for option in poll.options.all %}
<li class="list-group-item">{{ option.choice_text }}</li>
{% endfor %}
</ul>
{% else %}
<p>No options are listed.</p>
{% endif %}
</div>
{% endblock %}

View file

@ -0,0 +1,17 @@
{% extends "bases/bootstrap-with-nav.html" %}
{% load staticfiles %}
{% load bootstrap3 %}
{% block content %}
<div class="container">
<h1>Vote on {{poll.question_text}}</h1>
{% load crispy_forms_tags %}
<form method="post" action="" class="">
{% crispy vote_form %}
<input class="btn btn-default" type="submit" value="Submit"/>
</form>
</div>
{% endblock %}