2016-12-05 22:49:13 +00:00
|
|
|
{% extends "core/base.jinja" %}
|
|
|
|
|
|
|
|
{% block title %}
|
2016-12-21 17:19:43 +00:00
|
|
|
{{object.title}}
|
2016-12-05 22:49:13 +00:00
|
|
|
{% endblock %}
|
|
|
|
|
2016-12-21 17:19:43 +00:00
|
|
|
{% block head %}
|
|
|
|
{{ super() -}}
|
|
|
|
<style type="text/css">
|
2016-12-21 20:17:31 +00:00
|
|
|
time {
|
2016-12-22 00:57:17 +00:00
|
|
|
font-weight: bolder;
|
2016-12-21 20:17:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
th {
|
2016-12-22 00:57:17 +00:00
|
|
|
padding: 5px;
|
|
|
|
margin: 5px;
|
|
|
|
border: solid 1px darkgrey;
|
|
|
|
border-collapse: collapse;
|
|
|
|
vertical-align: top;
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
2016-12-21 23:16:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.election__title {
|
2016-12-22 00:57:17 +00:00
|
|
|
margin: 0;
|
2016-12-21 23:16:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.election__description {
|
2016-12-22 00:57:17 +00:00
|
|
|
margin: 0;
|
|
|
|
margin-top: 5px;
|
2016-12-21 23:16:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.election__details {
|
2016-12-22 00:57:17 +00:00
|
|
|
margin: 0;
|
|
|
|
margin-bottom: 5px;
|
2016-12-21 20:17:31 +00:00
|
|
|
}
|
|
|
|
|
2016-12-22 21:00:02 +00:00
|
|
|
.election__elector-infos {
|
|
|
|
margin: 0;
|
|
|
|
margin-bottom: 5px;
|
|
|
|
font-weight: bolder;
|
|
|
|
color: darkgreen;
|
|
|
|
}
|
|
|
|
|
|
|
|
.election__vote {
|
|
|
|
margin-bottom: 5px;
|
|
|
|
}
|
|
|
|
|
2016-12-22 20:16:46 +00:00
|
|
|
.election__vote-form {
|
|
|
|
width: auto;
|
|
|
|
}
|
|
|
|
|
2016-12-21 20:17:31 +00:00
|
|
|
.role {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-12-21 23:16:48 +00:00
|
|
|
.role .role__title {
|
2016-12-22 00:57:17 +00:00
|
|
|
background: lightgrey;
|
2016-12-21 23:16:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.role__multiple-choices {
|
2016-12-22 00:57:17 +00:00
|
|
|
color: darkgreen;
|
2016-12-21 23:16:48 +00:00
|
|
|
}
|
|
|
|
|
2016-12-22 20:16:46 +00:00
|
|
|
.role__error {
|
|
|
|
color: darkred;
|
|
|
|
}
|
|
|
|
|
2016-12-21 23:16:48 +00:00
|
|
|
.role .role_candidates {
|
2016-12-22 00:57:17 +00:00
|
|
|
background: white;
|
2016-12-21 23:16:48 +00:00
|
|
|
}
|
|
|
|
|
2016-12-21 20:17:31 +00:00
|
|
|
.list-per-role {
|
2016-12-22 00:57:17 +00:00
|
|
|
padding: 5px;
|
|
|
|
max-width: 310px;
|
2016-12-21 20:17:31 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
.list-per-role__candidates {
|
2016-12-22 00:57:17 +00:00
|
|
|
list-style: none;
|
|
|
|
margin: 0;
|
2016-12-21 23:16:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.list-per-role__candidate:not(:last-child) {
|
2016-12-22 00:57:17 +00:00
|
|
|
margin-bottom: 5px;
|
2016-12-21 20:17:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.candidate {
|
2016-12-22 00:57:17 +00:00
|
|
|
display: flex;
|
|
|
|
flex-flow: row nowrap;
|
2016-12-21 23:16:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.candidate__picture-wrapper {
|
2016-12-22 00:57:17 +00:00
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
2016-12-21 23:16:48 +00:00
|
|
|
|
2016-12-22 00:57:17 +00:00
|
|
|
width: 150px;
|
|
|
|
height: 150px;
|
2016-12-22 20:16:46 +00:00
|
|
|
min-width: 150px;
|
|
|
|
min-height: 150px;
|
2016-12-21 23:16:48 +00:00
|
|
|
|
2016-12-22 00:57:17 +00:00
|
|
|
background-color: lightgrey;
|
2016-12-21 23:16:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.candidate__picture {
|
2016-12-22 00:57:17 +00:00
|
|
|
max-width: 150px;
|
|
|
|
max-height: 150px;
|
2016-12-21 23:16:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.candidate__infos {
|
2016-12-22 00:57:17 +00:00
|
|
|
margin-left: 5px;
|
2016-12-21 23:16:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.candidate__full-name {
|
2016-12-22 00:57:17 +00:00
|
|
|
display: block;
|
2016-12-21 23:16:48 +00:00
|
|
|
|
2016-12-22 00:57:17 +00:00
|
|
|
font-weight: bolder;
|
2016-12-21 23:16:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.candidate__nick-name {
|
2016-12-22 00:57:17 +00:00
|
|
|
font-style: italic;
|
2016-12-21 23:16:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.candidate__program {
|
2016-12-22 00:57:17 +00:00
|
|
|
display: block;
|
|
|
|
margin-top: 5px;
|
2016-12-21 23:16:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.candidate__vote-input {
|
2016-12-22 00:57:17 +00:00
|
|
|
position: absolute;
|
|
|
|
border: 0;
|
|
|
|
height: 1px;
|
|
|
|
width: 1px;
|
|
|
|
padding: 0;
|
|
|
|
overflow: hidden;
|
|
|
|
clip: rect(0, 0, 0, 0);
|
2016-12-21 23:16:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.candidate__vote-choice {
|
2016-12-22 20:16:46 +00:00
|
|
|
margin-top: 5px;
|
|
|
|
padding: 15px;
|
2016-12-21 23:16:48 +00:00
|
|
|
|
2016-12-22 20:16:46 +00:00
|
|
|
border: solid 1px darkgrey;
|
2016-12-21 23:16:48 +00:00
|
|
|
|
2016-12-22 20:16:46 +00:00
|
|
|
color: dimgray;
|
|
|
|
text-align: center;
|
|
|
|
font-weight: bolder;
|
2016-12-21 23:16:48 +00:00
|
|
|
}
|
|
|
|
|
2016-12-22 21:00:02 +00:00
|
|
|
.candidate__vote-input:not(:disabled:checked) + .candidate__vote-choice:hover,
|
|
|
|
.candidate__vote-input:not(:disabled:checked) + .candidate__vote-choice:focus {
|
2016-12-22 00:57:17 +00:00
|
|
|
background: lightgrey;
|
2016-12-21 23:16:48 +00:00
|
|
|
}
|
2016-12-21 20:17:31 +00:00
|
|
|
|
2016-12-21 23:16:48 +00:00
|
|
|
.candidate__vote-input:checked + .candidate__vote-choice {
|
2016-12-22 20:16:46 +00:00
|
|
|
padding: 14px;
|
2016-12-22 00:57:17 +00:00
|
|
|
border-width: 2px;
|
|
|
|
border-color: darkgreen;
|
|
|
|
color: darkgreen;
|
2016-12-21 23:16:48 +00:00
|
|
|
}
|
|
|
|
|
2016-12-22 21:00:02 +00:00
|
|
|
.candidate__vote-input:not(:disabled) + .candidate__vote-choice {
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
|
|
|
|
.candidate__vote-input:checked:not(:disabled) + .candidate__vote-choice:hover,
|
|
|
|
.candidate__vote-input:checked:not(:disabled) + .candidate__vote-choice:focus {
|
2016-12-22 00:57:17 +00:00
|
|
|
background: palegreen;
|
2016-12-21 23:16:48 +00:00
|
|
|
}
|
|
|
|
|
2016-12-22 20:16:46 +00:00
|
|
|
.role_error .candidate__vote-input:checked + .candidate__vote-choice {
|
|
|
|
border-color: darkred;
|
|
|
|
color: darkred;
|
|
|
|
}
|
|
|
|
|
2016-12-22 21:00:02 +00:00
|
|
|
.role_error .candidate__vote-input:checked:not(:disabled) + .candidate__vote-choice:hover,
|
|
|
|
.role_error .candidate__vote-input:checked:not(:disabled) + .candidate__vote-choice:focus {
|
2016-12-22 20:16:46 +00:00
|
|
|
background: indianred;
|
|
|
|
}
|
|
|
|
|
2016-12-21 23:16:48 +00:00
|
|
|
.election__sumbit-section {
|
2016-12-22 00:57:17 +00:00
|
|
|
margin-top: 5px;
|
2016-12-21 23:16:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.election__sumbit-button {
|
2016-12-22 00:57:17 +00:00
|
|
|
display: block;
|
|
|
|
width: 100%;
|
|
|
|
padding: 20px;
|
|
|
|
background: white;
|
2016-12-22 20:16:46 +00:00
|
|
|
border: solid 15px #4081cb;
|
2016-12-22 00:57:17 +00:00
|
|
|
text-align: center;
|
|
|
|
font-size: 200%;
|
|
|
|
font-weight: bolder;
|
|
|
|
cursor: pointer;
|
2016-12-21 20:17:31 +00:00
|
|
|
}
|
2016-12-22 20:16:46 +00:00
|
|
|
|
|
|
|
.election__sumbit-button:hover,
|
|
|
|
.election__sumbit-button:focus {
|
|
|
|
background-color: lightskyblue;
|
|
|
|
}
|
2016-12-22 21:00:02 +00:00
|
|
|
|
|
|
|
.election__add-elements a {
|
|
|
|
display: inline-block;
|
|
|
|
border: solid 1px darkgrey;
|
|
|
|
height: 20px;
|
|
|
|
line-height: 20px;
|
|
|
|
padding: 10px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.election__add-candidature {
|
|
|
|
margin-top: 5px;
|
|
|
|
}
|
2016-12-21 17:19:43 +00:00
|
|
|
</style>
|
|
|
|
{%- endblock %}
|
|
|
|
|
2016-12-05 22:49:13 +00:00
|
|
|
{% block content %}
|
2016-12-22 20:16:46 +00:00
|
|
|
<h3 class="election__title">{{ election.title }}</h3>
|
|
|
|
<p class="election__description">{{ election.description }}</p>
|
2016-12-22 00:57:17 +00:00
|
|
|
<hr>
|
|
|
|
<section>
|
|
|
|
<p class="election__details">
|
|
|
|
{% trans %}Polls close {% endtrans %}
|
|
|
|
<time datetime="{{ election.end_date }}">{{ election.end_date|date("l d F Y") }}</time> at <time>{{ election.end_date|time("G:i") }}</time>
|
|
|
|
</p>
|
2016-12-22 20:16:46 +00:00
|
|
|
{%- if election.has_voted(request.user) %}
|
2016-12-22 00:57:17 +00:00
|
|
|
<p class="election__elector-infos">
|
|
|
|
<span>{% trans %}You already have submitted your vote.{% endtrans %}</span>
|
|
|
|
</p>
|
|
|
|
{%- endif %}
|
2016-12-22 20:16:46 +00:00
|
|
|
</section>
|
2016-12-22 21:00:02 +00:00
|
|
|
<section class="election__vote">
|
2016-12-22 20:16:46 +00:00
|
|
|
<form action="/election/1/vote" method="post" class="election__vote-form" name="vote-form" id="vote-form">
|
|
|
|
{% csrf_token %}
|
|
|
|
<table>
|
|
|
|
{%- set election_lists = election.election_list.all() -%}
|
|
|
|
<caption></caption>
|
|
|
|
<thead>
|
|
|
|
<th>{% trans %}Blank vote{% endtrans %}</th>
|
2016-12-22 00:57:17 +00:00
|
|
|
{%- for election_list in election_lists %}
|
2016-12-22 20:16:46 +00:00
|
|
|
<th>{{election_list.title}}</th>
|
2016-12-22 00:57:17 +00:00
|
|
|
{%- endfor %}
|
2016-12-22 20:16:46 +00:00
|
|
|
</thead>
|
|
|
|
{%- for role in election.role.all() %}
|
|
|
|
{%- set count = [0] %}
|
|
|
|
{%- set role_data = election_form.data.getlist(role.title) if role.title in election_form.data else [] %}
|
|
|
|
<tbody class="role {% if election_form.errors[role.title] is defined %}role_error{% endif %}">
|
|
|
|
<tr class="role__title">
|
|
|
|
<td colspan="{{election_lists.count() + 1}}">
|
|
|
|
<span>{{role.title}}</span>
|
|
|
|
{%- if role.max_choice > 1 %}
|
|
|
|
<strong class="role__multiple-choices">{% trans %}You may choose up to{% endtrans %} {{ role.max_choice }} {% trans %}people.{% endtrans %}</strong>
|
|
|
|
{%- endif %}
|
|
|
|
{%- if election_form.errors[role.title] is defined %}
|
|
|
|
{%- for error in election_form.errors.as_data()[role.title] %}
|
|
|
|
<strong class="role__error">{{ error.message }}</strong>
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr class="role_candidates">
|
|
|
|
<td class="list-per-role">
|
|
|
|
{%- if election.is_active and role.max_choice == 1 %}
|
2016-12-22 21:00:02 +00:00
|
|
|
<input id="id_{{ role.title }}_{{ count[0] }}" class="candidate__vote-input" type="radio" name="{{ role.title }}" value {{ '' if role_data in election_form else 'checked' }} {{ 'disabled' if election.has_voted(request.user) else '' }}>
|
2016-12-22 20:16:46 +00:00
|
|
|
<label for="id_{{ role.title }}_{{ count[0] }}" class="candidate__vote-choice">
|
|
|
|
<span>{% trans %}Choose blank vote{% endtrans %}</span>
|
|
|
|
</label>
|
|
|
|
{%- set _ = count.append(count.pop() + 1) %}
|
|
|
|
{%- endif %}
|
|
|
|
</td>
|
|
|
|
{%- for election_list in election_lists %}
|
|
|
|
<td class="list-per-role">
|
|
|
|
<ul class="list-per-role__candidates">
|
|
|
|
{%- for candidature in election_list.candidature.filter(role=role) %}
|
|
|
|
<li class="list-per-role__candidate">
|
|
|
|
<figure class="candidate">
|
|
|
|
<div class="candidate__picture-wrapper">
|
|
|
|
{%- if candidature.user.profile_pict %}
|
|
|
|
<img class="candidate__picture" src="{{candidature.user.profile_pict.get_download_url()}}" alt="{% trans %}Profile{% endtrans %}">
|
|
|
|
{%- endif %}
|
|
|
|
</div>
|
|
|
|
<figcaption class="candidate__infos">
|
|
|
|
<cite class="candidate__full-name">{{ candidature.user.first_name }} <em class="candidate__nick-name">{{candidature.user.nick_name or ''}} </em>{{ candidature.user.last_name }}</cite>
|
|
|
|
<q class="candidate__program">{{ candidature.program or '' }}</q>
|
|
|
|
</figcaption>
|
|
|
|
</figure>
|
|
|
|
{%- if election.is_active %}
|
2016-12-22 21:00:02 +00:00
|
|
|
<input id="id_{{ role.title }}_{{ count[0] }}" type="{{ 'checkbox' if role.max_choice > 1 else 'radio' }}" {{ 'checked' if candidature.id|string in role_data else '' }} {{ 'disabled' if election.has_voted(request.user) else '' }} name="{{ role.title }}" value="{{ candidature.id }}" class="candidate__vote-input">
|
2016-12-22 20:16:46 +00:00
|
|
|
<label for="id_{{ role.title }}_{{ count[0] }}" class="candidate__vote-choice">
|
|
|
|
<span>{% trans %}Choose{% endtrans %} {{ candidature.user.nick_name or candidature.user.first_name }}</span>
|
|
|
|
</label>
|
|
|
|
{%- set _ = count.append(count.pop() + 1) %}
|
|
|
|
{%- endif %}
|
|
|
|
</li>
|
|
|
|
{%- endfor %}
|
|
|
|
</ul>
|
|
|
|
</td>
|
|
|
|
{%- endfor %}
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
{%- endfor %}
|
|
|
|
</table>
|
|
|
|
</form>
|
2016-12-22 00:57:17 +00:00
|
|
|
</section>
|
2016-12-22 21:00:02 +00:00
|
|
|
{%- if not election.has_voted(request.user) %}
|
2016-12-22 00:57:17 +00:00
|
|
|
<section class="election__sumbit-section">
|
2016-12-22 20:16:46 +00:00
|
|
|
<button class="election__sumbit-button" form="vote-form">{% trans %}Submit the vote !{% endtrans %}</button>
|
2016-12-22 00:57:17 +00:00
|
|
|
</section>
|
2016-12-22 21:00:02 +00:00
|
|
|
{%- endif %}
|
|
|
|
{%- if request.user.can_edit(election) %}
|
2016-12-22 20:16:46 +00:00
|
|
|
<section class="election__add-elements">
|
|
|
|
<a href="{{url('election:create_list')}}">{% trans %}Add a new list{% endtrans %}</a>
|
|
|
|
<a href="{{url('election:create_role')}}">{% trans %}Add a new role{% endtrans %}</a>
|
|
|
|
</section>
|
2016-12-22 21:00:02 +00:00
|
|
|
{%- endif %}
|
|
|
|
{%- if election.can_candidate(request.user) %}
|
|
|
|
<section class="election__add-candidature">
|
|
|
|
<form action="{{url('election:candidate', election_id=election.id)}}" method="post">{{candidate_form}}
|
|
|
|
{% csrf_token %}
|
|
|
|
<p><input type="submit" value="{% trans %}Candidate{% endtrans %}" /></p>
|
|
|
|
</form>
|
|
|
|
</section>
|
|
|
|
{%- endif %}
|
2016-12-05 22:49:13 +00:00
|
|
|
{% endblock %}
|