election_detail.jinja 5.86 KB
Newer Older
Sli's avatar
Sli committed
1
2
3
{% extends "core/base.jinja" %}

{% block title %}
4
{{object.title}}
Sli's avatar
Sli committed
5
6
{% endblock %}

7
8
9
{% block head %}
{{ super() -}}
<style type="text/css">
10
time {
11
	font-weight: bolder;
12
13
14
}

th {
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
	padding: 5px;
	margin: 5px;
	border: solid 1px darkgrey;
	border-collapse: collapse;
	vertical-align: top;
	overflow: hidden;
	text-overflow: ellipsis;
}

.election__title {
	margin: 0;
}

.election__description {
	margin: 0;
	margin-top: 5px;
}

.election__details {
	margin: 0;
	margin-bottom: 5px;
36
37
38
39
40
41
}

.role {

}

42
43
44
45
46
47
48
49
50
51
52
53
.role .role__title {
	background: lightgrey;
}

.role__multiple-choices {
	color: darkgreen;
}

.role .role_candidates {
	background: white;
}

54
.list-per-role {
55
56
	padding: 5px;
	max-width: 310px;
57
58
59
60
61

}

.list-per-role__candidates {
	list-style: none;
62
63
64
65
66
	margin: 0;
}

.list-per-role__candidate:not(:last-child) {
	margin-bottom: 5px;
67
68
69
}

.candidate {
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
	display: flex;
	flex-flow: row nowrap;
}

.candidate__picture-wrapper {
	display: flex;
	justify-content: center;
	align-items: center;

	width: 150px;
	height: 150px;

	background-color: lightgrey;
}

.candidate__picture {
	max-width: 150px;
	max-height: 150px;
}

.candidate__infos {
	margin-left: 5px;
}

.candidate__full-name {
	display: block;

	font-weight: bolder;
}

.candidate__nick-name {
	font-style: italic;
}

.candidate__program {
	display: block;
	margin-top: 5px;
}

.candidate__vote-input {
	position: absolute;
	border: 0;
	height: 1px;
	width: 1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
}

.candidate__vote-choice {
		margin-top: 5px;
		padding: 15px;

		border: solid 1px darkgrey;

		text-align: center;
		cursor: pointer;
}

.candidate__vote-choice:hover, .candidate__vote-choice:focus {
	background: lightgrey;
}
132

133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
.candidate__vote-input:checked + .candidate__vote-choice {
	border-width: 2px;
	border-color: darkgreen;
	color: darkgreen;
	font-weight: bolder;
}

.candidate__vote-input:checked + .candidate__vote-choice:hover,
.candidate__vote-input:checked + .candidate__vote-choice:focus {
	background: palegreen;
}

.election__sumbit-section {
	margin-top: 5px;
}

.election__sumbit-button {
	display: block;
	width: 100%;
	padding: 20px;
	background: white;
	border: solid 15px orange;
	text-align: center;
	font-size: 200%;
	font-weight: bolder;
	cursor: pointer;
159
}
160
161
162
</style>
{%- endblock %}

Sli's avatar
Sli committed
163
{% block content %}
164
165
	<h3 class="election__title">{{ object.title }}</h3>
	<p class="election__description">{{ object.description }}</p>
166
167
	<hr>
	<section>
168
169
170
171
172
173
174
175
176
		<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>
		{%- if object.has_voted(request.user) %}
		<p class="election__elector-infos">
			<span>{% trans %}You already have submitted your vote.{% endtrans %}</span>
		</p>
		{%- endif %}
177
178
179
180
181
182
183
184
185
	</section>
	<section>
		<table>
			{%- set election_lists = object.election_list.all() -%}
			<caption></caption>
			<thead>
				{%- for election_list in election_lists %}
				<th>{{election_list.title}}</th>
				{%- endfor %}
186
				<th>{% trans %}Blank vote{% endtrans %}</th>
187
188
			</thead>
			{%- for role in object.role.all() %}
189
			<tbody class="role">
190
191
192
193
194
195
196
197
198
				<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 %}
					</td>
				</tr>
				<tr class="role_candidates">
199
					{%- for election_list in election_lists %}
200
201
					<td class="list-per-role">
						<ul class="list-per-role__candidates">
202
						{%- for candidature in election_list.candidature.filter(role=role) %}
203
							<li class="list-per-role__candidate">
204
								<figure class="candidate">
205
206
207
208
209
210
211
212
									<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>
213
214
									</figcaption>
								</figure>
215
216
217
218
219
220
								{%- if object.is_active %}
								<input id="id" class="candidate__vote-input" type="radio" name="vote">
								<label for="id" class="candidate__vote-choice">
									<span>{% trans %}Choose{% endtrans %} {{ candidature.user.nick_name or candidature.user.first_name }}</span>
								</label>
								{% endif %}
221
222
223
224
225
							</li>
						{%- endfor %}
						</ul>
					</td>
					{%- endfor %}
226
227
228
229
230
231
232
233
					<td class="list-per-role">
						{%- if object.is_active %}
						<input id="id" class="candidate__vote-input" type="radio" name="vote">
						<label for="id" class="candidate__vote-choice">
							<span>{% trans %}Choose blank vote{% endtrans %}</span>
						</label>
						{% endif %}
					</td>
234
235
236
237
238
				</tr>
			</tbody>
			{%- endfor %}
		</table>
	</section>
239
240
241
	<section class="election__sumbit-section">
		<button class="election__sumbit-button">{% trans %}Submit the vote !{% endtrans %}</button>
	</section>
Sli's avatar
Sli committed
242
243
	<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>
Sli's avatar
Sli committed
244
245
	<form action="{{url('election:candidate', election_id=object.id)}}" method="post">{{candidate_form}}
	{% csrf_token %}
Sli's avatar
Sli committed
246
247
248
249
250
251
    <p><input type="submit" value="{% trans %}Candidate{% endtrans %}" /></p>
	</form>
	<form action="{{url('election:vote', election_id=object.id)}}" method="post">
	{{election_form.as_p()}}
    <p><input type="submit" value="{% trans %}Vote{% endtrans %}" /></p>
	{% csrf_token %}
Sli's avatar
Sli committed
252
	</form>
Sli's avatar
Sli committed
253
{% endblock %}