a832684f13f8dca9b87e9bfef0b1fb1441463bf3
[cavote.git] / templates / vote.html
1 {% extends "layout.html" %}
2 {% block subtitle %}{{vote.title}}{% endblock %}
3 {% block body %}
4 <div class="row">
5 <div class="span3">
6 <h2 class="page-header">Informations</h2>
7 <div class="progress progress-striped progress-{% if vote.nb_votes > 0 and vote.nb_votes / vote.max_votes >= vote.quorum %}success{% else %}danger{% endif %}">
8 <div class="bar" style="width: {{ vote.percent }}%;">
9 <strong>{{ vote.nb_votes }} vote{{ 's' if vote.nb_votes > 1 else '' }} / {{ vote.max_votes }} ({{ vote.percent }}%)</strong></div>
10 </div>
11 <dl class="dl-horizontal">
12 <dt>Publié par <dd><code>{{ vote.author }}</code>
13 <dt>Début le <dd><code>{{ vote.date_begin }}</code>
14 <dt>Fin le <dd><code>{{ vote.date_end }}</code>
15 <dt>Groupe <dd><code>{{ vote.groupname }}</code>
16 <dt>Catégorie <dd><code>{{ vote.category }}</code>
17 <dt>Quorum <dd><code>{{ vote.quorum * 100 }}%</code>
18 </dl>
19 <dl>
20 {% if vote.description %}
21 <dt>Description : <dd>{{ vote.description }}
22 {% endif %}
23 {% if attachments %}
24 <dt>Documents :<dd>
25 <ul>
26 {% for attachment in attachments %}
27 <li><a href="{{ attachment.url }}">{{ attachment.url }}</a></li>
28 {% endfor %}
29 </ul>
30 {% endif %}
31 </dl>
32 </div>
33
34 {% if vote.is_transparent or (session.user and user.userid == session.user.id )%}
35 <div class="span8">
36 <h2 class='page-header'>Résultats</h2>
37 <svg class="results cardinal-{{ vote.id_cardinal }}"
38 width="{{ 150 + (100 * 5) + 50 + 100 + 100 }}"
39 height="{{25 + results.list|length * 20 + 40}}">
40 <g class="choice" transform="translate(100,0)">
41 <text class="choice-legend" x="-10" y="9.5" dy=".35em">Légende :</text>
42 </g>
43 {% for value in values %}
44 <g transform="translate({{ 150 + (loop.index0 * 640 / loop.length) }},0)">
45 <rect width="{{ 640 / loop.length }}" height="20"></rect>
46 <rect class="{{ value.class }}" x="1" y ="1" width="{{ 640 / loop.length - 1}}" height="19"></rect>
47 <text class="choice-legend-item" text-anchor="start" x="{{ 640 / loop.length - 2 }}" y="9.5" dy=".35em"
48 >{{ value.name }}</text>
49 </g>
50 {% endfor %}
51 <g transform="translate({{150 + (100 * 5) + 35}},20)">
52 <text class="choice-sum-legend" x="20" y="9.5" dy=".35em">somme↓</text>
53 </g>
54 <g transform="translate({{150 + (100 * 5) + 115}},20)">
55 <text class="choice-average-legend" x="20" y="9.5" dy=".35em">moyenne↓</text>
56 </g>
57 {% for choice in results.list %}
58 <g class="choice" transform="translate(150,{{ 35 + loop.index0 * 20 }})">
59 <text class="choice" x="-10" y="9.5" dy=".35em">{{ choice.name }}</text>
60 </g>
61 {% set choice_loop = loop %}
62 {% for value in choice.values_ %}
63 <g transform="translate({{ 150 + (value.previous_percent * 5) }},{{ 35 + choice_loop.index0 * 20 }})">
64 {% if value.percent > 0 %}
65 <rect class="{{ value.class }}" width="{{ (value.percent * 5)|int }}" height="19"></rect>
66 <text text-anchor="middle" x="{{ (value.percent * 5 / 2 + 10)|int }}" y="9.5" dy=".35em"
67 >{{ value.percent|int }}%</text>
68 {% endif %}
69 </g>
70 {% endfor %}
71 <g transform="translate({{150 + (100 * 5) + 35}},{{35 + loop.index0 * 20}})">
72 <text class="choice-sum" x="20" y="9.5" dy=".35em">{{ choice.sum }}</text>
73 </g>
74 <g transform="translate({{150 + (100 * 5) + 115}},{{35 + loop.index0 * 20}})">
75 <text class="choice-average" x="20" y="9.5" dy=".35em">{{ "%.2f"|format(choice.average) }}</text>
76 </g>
77 {% if loop.length > 1 and choice.id in results.medians %}
78 <g transform="translate({{150 + (100 * 5) + 125}},{{35 + loop.index0 * 20}})">
79 <text class="choice-median" x="75" y="9.5" dy=".35em">← médiane</text>
80 </g>
81 {%endif%}
82 {% endfor %}
83 <g class="axis" transform="translate(150,{{35 + results.list|length * 20}})">
84 <g transform="translate(0,0)" style="opacity: 1;" class="tick">
85 <line x1="0" y1="6" x2="0" y2="0"></line>
86 <text style="text-anchor: middle;" dy=".71em" x="0" y="9">0%</text>
87 </g>
88 <g transform="translate(125,0)" style="opacity: 1;" class="tick">
89 <line x1="0" y1="6" x2="0" y2="0"></line>
90 <text style="text-anchor: middle;" dy=".71em" x="0" y="9">25%</text>
91 </g>
92 <g transform="translate(250,0)" style="opacity: 1;" class="tick">
93 <line x1="0" y1="6" x2="0" y2="0"></line>
94 <text style="text-anchor: middle;" dy=".71em" x="0" y="9">50%</text>
95 </g>
96 <g transform="translate(375,0)" style="opacity: 1;" class="tick">
97 <line x1="0" y1="6" x2="0" y2="0"></line>
98 <text style="text-anchor: middle;" dy=".71em" x="0" y="9">75%</text>
99 </g>
100 <g transform="translate(500,0)" style="opacity: 1;" class="tick">
101 <line x1="0" y1="6" x2="0" y2="0"></line>
102 <text style="text-anchor: middle;" dy=".71em" x="0" y="9">100%</text>
103 </g>
104 <path d="M0,6V0H500V6" class="domain"></path>
105 </g>
106 </svg>
107 </div>
108 {% endif %}
109
110 <div class="span9">
111 <h2 class='page-header'>Suffrages</h2>
112 {% if vote.is_anonymous %}
113 <div class="alert alert-info">Ce vote est anonymisé, les suffrages ne sont ni visibles ni modifiables.</div>
114 {% endif %}
115 {% if not vote.is_transparent %}
116 <div class="alert alert-info">Ce vote n’est pas transparent, vous ne pouvez pas voir les votes des autres.</div>
117 {% endif %}
118
119 {% if (vote['is_anonymous'] and can_vote) or not vote['is_anonymous'] %}
120 <table class="table table-condensed table-bordered table-votes cardinal-{{ vote.id_cardinal }}">
121 <thead>
122 <tr>
123 <th></th>
124 {% for choice in choices %}
125 <th class="choice-name">{{ choice.name }}</th>
126 {% endfor %}
127 {% if 'user' in session and (can_vote or (not vote['is_terminated'] and not vote['is_anonymous'])) %}
128 <th></th>
129 {% endif %}
130 </tr>
131 {% if vote.is_transparent %}
132 <!--
133 <tr>
134 <th>Somme</th>
135 {% for choice in choices %}
136 <td>{{ choice.sum }}</td>
137 {% endfor %}
138 {% if 'user' in session and (can_vote or (not vote['is_terminated'] and not vote['is_anonymous'])) %}
139 <td></td>
140 {% endif %}
141 </tr>
142 -->
143 {% endif %}
144
145 {% if can_vote %}
146 <form class="form-inline" action="{{ url_for('vote', idvote=vote.id) }}" method="post">
147 <tr>
148 <th><input type='text' name="username" value='{{ session.user.name }}' disabled /></th>
149 {% for choice in choices %}
150 <td>
151 <select name="value-{{ choice.id }}" id="value-{{ choice.id }}">
152 {% for value in values %}
153 <option value="{% if value.weight is not none %}{{ value.weight }}{% endif %}" class="{{ value.class }}">{{ value.name }}</option>
154 {% endfor %}
155 </select>
156 </td>
157 {% endfor %}
158 <td><input type="submit" class="btn btn-primary" value="OK" /></td>
159 </tr>
160 </form>
161 {% endif %}
162 </thead>
163
164 {% if not vote['is_anonymous'] %}
165 <tbody>
166 {% for user in users %}
167 {% if vote.is_transparent or (session.user and user.userid == session.user.id )%}
168 <tr>
169 <th>{% if 'user' in session and user.userid == session.user.id %}<i class="icon-user"></i>{% endif %} {{ user.username }}</th>
170 {% for choice in choices %}
171 <td class="{{user.choices[choice.id].class}}"><span>{{ user.choices[choice.id].name }}</span></td>
172 {% endfor %}
173 {% if 'user' in session and (can_vote or (not vote['is_terminated'] and not vote['is_anonymous'])) %}
174 <td>{% if user.userid == session.user.id %}
175 <a href="#delete" data-toggle="modal" class="btn btn-danger btn-mini" title="Supprimer"><i class="icon-remove icon-white"></i></a>
176 <div class="modal hide fade" id="delete">
177 <div class="modal-header">
178 <button type="button" class="close" data-dismiss="modal">×</button>
179 <h3>Suppression de votre vote</h3>
180 </div>
181 <div class="modal-body">
182 <p>Voulez-vous vraiment supprimer votre vote ?</p>
183 </div>
184 <div class="modal-footer">
185 <a href="{{ url_for('vote_deletechoices', idvote=vote.id, iduser=session.user.id) }}" class="btn btn-danger">Confirmer</a>
186 <a href="#" class="btn" data-dismiss="modal">Annuler</a>
187 </div>
188 </div>
189 {% endif %}</td>
190 {% endif %}
191 </tr>
192 {% endif %}
193 {% endfor %}
194 </tbody>
195 {% endif %}
196 </table>
197 {% else %}
198 {% if not can_vote %}
199 <div class="alert alert-info">Vous avez déjà voté.</div>
200 {% endif %}
201 {% endif %}
202 </div>
203
204 </div>
205 {% endblock %}
206