Users can see waiting votes, votes can be terminated
[cavote.git] / templates / vote.html
index 3ebec2a..8d6e9dd 100644 (file)
@@ -3,36 +3,52 @@
 <div class="row">
 <div class="span9">
 <h2 class='page-header'>{{ vote.title }}</h2>
-<table class="table table-condensed table-striped table-bordered">
+{% if not vote.is_transparent %}
+<div class="alert alert-info">Ce sondage n'est pas transparent, vous ne pouvez pas voir les votes des autres.</div>
+{% endif %}
+
+<table class="table table-condensed table-bordered table-votes">
   <thead>
     <tr>
       <th></th>
       {% for choice in choices %}
       <th>{{ choice.name }}</th>
       {% endfor %}
+      {% if 'user' in 'session' %}
       <th></th>
+      {% endif %}
     </tr>
   </thead>
 
   <tbody>
-  {% if vote.is_transparent %}
-  <!-- :TODO:maethor:20120528: Afficher les votes ici -->
-  {% else %}
-    <div class="alert alert-info">Ce sondage n'est pas transparent, vous ne pouvez pas voir les votes des autres.</div>
-    <!-- :TODO:maethor:20120528: Afficher le vote de l'utilisateur -->
+  {% for user in users %}
+  {% if vote.is_transparent or user.userid == session.user.id %}
+    <tr>
+      <th>{% if 'user' in session and user.userid == session.user.id %}<i class="icon-user"></i>{% endif %} {{ user.username }}</th>
+      {% for choice in choices %}
+      {% if choice.id in user.choices %}
+      <td class="yes"><i class="icon-ok icon-white"></i></td>
+      {% else %}
+      <td class="no"></td>{% endif %}
+      {% endfor %}
+      {% if 'user' in 'session' %}
+      <td>{% if user.userid == session.user.id %}<a href="{{ url_for('vote_deletechoices', idvote=vote.id, iduser=session.user.id) }}" class="btn btn-mini btn-danger" title="Supprimer"><i class="icon-remove icon-white"></a>{% endif %}</td>
+      {% endif %}
+    </tr>
   {% endif %}
+  {% endfor %}
 
   {% if can_vote %}
-    <form class="form-inline" action=""> <!-- :TODO:maethor:20120528: Route -->
+    <form class="form-inline" action="{{ url_for('vote', idvote=vote.id) }}" method="post">
     <tr>
-      <td><input type='text' name="username" value='{{ session.user.name }}' disabled /></td>
-      {% if vote.is_multiple %}
+      <th><input type='text' name="username" value='{{ session.user.name }}' disabled /></th>
+      {% if vote.is_multiplechoice %}
       {% for choice in choices %}
       <td><input type='checkbox' name="{{ choice.id }}" /></td>
       {% endfor %}
       {% else %}
       {% for choice in choices %}
-      <td><input type='radio' name="choice" value="{{ choice.id }}" /></td>
+      <td><input type='radio' name="{{ choice.id }}" /></td>
       {% endfor %}
       {% endif %}
       <td><input type="submit" class="btn btn-primary" value="OK" /></td>
     </form>
   {% endif %}
   </tbody>
+
   <tfoot>
   {% if vote.is_transparent %}
     <tr>
-      <td style="text-align: right">Somme</td>
+      <th>Somme</th>
       {% for choice in choices %}
-      <td>nb</td>
+      <td>{{ choice.nb }}</td>
       {% endfor %}
+      {% if 'user' in 'session' %}
       <td></td>
+      {% endif %}
     </tr>
   {% endif %}
   </tfoot>
 
 <div class="span3">
 <h3>Informations</h3>
+<strong>Avancement : </strong> {{ vote.nb_votes }} / {{ vote.max_votes }}
+<div class="progress progress-striped {% if vote.nb_votes == vote.max_votes %}progress-success{% endif %}">
+  <div class="bar" style="width: {{ vote.percent }}%;"></div>
+</div>
 <dl class="dl-horizontal">
   <dt>Publié par <dd><code>maethor</code>
   <dt>Début le <dd><code>{{ vote.date_begin }}</code>
-  <dt>Fin le <dd><code>{{ vote.date_end }}</code>
-  <dt>Groupe <dd><code>{{ vote.rolename }}</code>
+  <dt>Deadline le <dd><code>{{ vote.date_end }}</code>
+  <dt>Groupe <dd><code>{{ vote.groupname }}</code>
   <dt>Catégorie <dd><code>{{ vote.category }}</code>
 </dl>
 <dl>