vote.html 9.0 KB

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