{% extends "layout.html" %}
+{% block subtitle %}{{vote.title}}{% endblock %}
{% block body %}
<div class="row">
+<div class="span3">
+<h2 class="page-header">Informations</h2>
+<div class="progress progress-striped progress-{% if vote.nb_votes > 0 and vote.nb_votes / vote.max_votes >= vote.quorum %}success{% else %}danger{% endif %}">
+ <div class="bar" style="width: {{ vote.percent }}%;">
+ <strong>{{ vote.nb_votes }} vote{{ 's' if vote.nb_votes > 1 else '' }} / {{ vote.max_votes }} ({{ vote.percent }}%)</strong></div>
+</div>
+<dl class="dl-horizontal">
+ <dt>Publié par <dd><code>{{ vote.author }}</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.groupname }}</code>
+ <dt>Catégorie <dd><code>{{ vote.category }}</code>
+ <dt>Quorum <dd><code>{{ vote.quorum * 100 }}%</code>
+</dl>
+<dl>
+ {% if vote.description %}
+ <dt>Description : <dd>{{ vote.description }}
+ {% endif %}
+ {% if attachments %}
+ <dt>Documents :<dd>
+ <ul>
+ {% for attachment in attachments %}
+ <li><a href="{{ attachment.url }}">{{ attachment.url }}</a></li>
+ {% endfor %}
+ </ul>
+ {% endif %}
+</dl>
+</div>
+
+{% if vote.is_transparent or (session.user and user.userid == session.user.id )%}
+<div class="span8">
+ <h2 class='page-header'>Résultats</h2>
+ <svg class="results cardinal-{{ vote.id_cardinal }}"
+ width="{{ 150 + (100 * 5) + 100 + 100 }}"
+ height="{{25 + results.list|length * 20 + 40}}">
+ <g class="choice" transform="translate(100,0)">
+ <text class="choice-legend" x="-10" y="9.5" dy=".35em">Légende :</text>
+ {% for value in values %}
+ <g transform="translate({{ (loop.index0 * 750 / loop.length) }},0)">
+ <rect width="{{ 750 / loop.length + 1 }}" height="18"></rect>
+ <rect class="{{ value.class }}" x="1" y ="0" width="{{ 750 / loop.length - 1}}" height="18"></rect>
+ <text class="choice-legend-item" text-anchor="start" x="{{ 750 / loop.length - 2 }}" y="9.5" dy=".35em"
+ >{{ value.name }}</text>
+ </g>
+ {% endfor %}
+ </g>
+ <g transform="translate({{150 + (100 * 5) + 35}},20)">
+ <text class="choice-sum-legend" x="20" y="9.5" dy=".35em">somme↓</text>
+ </g>
+ <g transform="translate({{150 + (100 * 5) + 115}},20)">
+ <text class="choice-average-legend" x="20" y="9.5" dy=".35em">moyenne↓</text>
+ </g>
+ {% for choice in results.list %}
+ <g class="choice" transform="translate(150,{{ 35 + loop.index0 * 20 }})">
+ <text class="choice" x="-10" y="9.5" dy=".35em">{{ choice.name }}</text>
+ </g>
+ {% set choice_loop = loop %}
+ {% for value in choice.values_ %}
+ <g transform="translate({{ 150 + (value.previous_percent * 5) }},{{ 35 + choice_loop.index0 * 20 }})">
+ {% if value.percent > 0 %}
+ <rect class="{{ value.class }}" width="{{ (value.percent * 5)|int }}" height="19"></rect>
+ <text text-anchor="middle" x="{{ (value.percent * 5 / 2 + 10)|int }}" y="9.5" dy=".35em"
+ >{{ value.percent|int }}%</text>
+ {% endif %}
+ </g>
+ {% endfor %}
+ <g transform="translate({{150 + (100 * 5) + 35}},{{35 + loop.index0 * 20}})">
+ <text class="choice-sum" x="20" y="9.5" dy=".35em">{{ choice.sum }}</text>
+ </g>
+ <g transform="translate({{150 + (100 * 5) + 115}},{{35 + loop.index0 * 20}})">
+ <text class="choice-average" x="20" y="9.5" dy=".35em">{{ "%.2f"|format(choice.average) }}</text>
+ </g>
+ {% if loop.length > 1 and choice.id in results.medians %}
+ <g transform="translate({{150 + (100 * 5) + 125}},{{35 + loop.index0 * 20}})">
+ <text class="choice-median" x="75" y="9.5" dy=".35em">← médiane</text>
+ </g>
+ {%endif%}
+ {% endfor %}
+ <g class="axis" transform="translate(150,{{35 + results.list|length * 20}})">
+ <g transform="translate(0,0)" style="opacity: 1;" class="tick">
+ <line x1="0" y1="6" x2="0" y2="0"></line>
+ <text style="text-anchor: middle;" dy=".71em" x="0" y="9">0%</text>
+ </g>
+ <g transform="translate(125,0)" style="opacity: 1;" class="tick">
+ <line x1="0" y1="6" x2="0" y2="0"></line>
+ <text style="text-anchor: middle;" dy=".71em" x="0" y="9">25%</text>
+ </g>
+ <g transform="translate(250,0)" style="opacity: 1;" class="tick">
+ <line x1="0" y1="6" x2="0" y2="0"></line>
+ <text style="text-anchor: middle;" dy=".71em" x="0" y="9">50%</text>
+ </g>
+ <g transform="translate(375,0)" style="opacity: 1;" class="tick">
+ <line x1="0" y1="6" x2="0" y2="0"></line>
+ <text style="text-anchor: middle;" dy=".71em" x="0" y="9">75%</text>
+ </g>
+ <g transform="translate(500,0)" style="opacity: 1;" class="tick">
+ <line x1="0" y1="6" x2="0" y2="0"></line>
+ <text style="text-anchor: middle;" dy=".71em" x="0" y="9">100%</text>
+ </g>
+ <path d="M0,6V0H500V6" class="domain"></path>
+ </g>
+ </svg>
+</div>
+{% endif %}
+
<div class="span9">
-<h2 class='page-header'>{{ vote.title }}</h2>
-<table class="table table-condensed table-striped table-bordered">
+ <h2 class='page-header'>Suffrages</h2>
+{% if vote.is_anonymous %}
+<div class="alert alert-info">Ce vote est anonymisé, les suffrages ne sont ni visibles ni modifiables.</div>
+{% endif %}
+{% if not vote.is_transparent %}
+<div class="alert alert-info">Ce vote n’est pas transparent, vous ne pouvez pas voir les votes des autres.</div>
+{% endif %}
+
+{% if (vote['is_anonymous'] and can_vote) or not vote['is_anonymous'] %}
+<table class="table table-condensed table-bordered table-votes cardinal-{{ vote.id_cardinal }}">
<thead>
<tr>
- <th></th>
+ <th class="users">Votant-e-s</th>
{% for choice in choices %}
- <th>{{ choice.name }}</th>
+ <th class="choice-name">{{ choice.name }}</th>
{% endfor %}
+ {% if 'user' in session and (can_vote or (not vote['is_terminated'] and not vote['is_anonymous'])) %}
<th></th>
+ {% else %}
+ <th class="comments">Commentaires</th>
+ {% endif %}
</tr>
- </thead>
-
- <tbody>
{% if vote.is_transparent %}
- {% for user in users %}
+ <!--
<tr>
- <td>{{ user.username }}</td>
+ <th>Somme</th>
{% for choice in choices %}
- <th>{% if choice in user.choices %}OUI{% else %}NON{% endif %}</th>
+ <td>{{ choice.sum }}</td>
{% endfor %}
+ {% if 'user' in session and (can_vote or (not vote['is_terminated'] and not vote['is_anonymous'])) %}
+ <td></td>
+ {% endif %}
</tr>
- {% endfor %}
- {% 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 -->
+ -->
{% endif %}
{% if can_vote %}
<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>
{% for choice in choices %}
- <td><input type='checkbox' name="{{ choice.id }}" /></td>
+ <td>
+ <select name="value-{{ choice.id }}" id="value-{{ choice.id }}">
+ {% for value in values %}
+ <option value="{% if value.weight is not none %}{{ value.weight }}{% endif %}" class="{{ value.class }}">{{ value.name }}</option>
+ {% endfor %}
+ </select>
+ </td>
{% endfor %}
- {% else %}
- {% for choice in choices %}
- <td><input type='radio' name="{{ choice.id }}" /></td>
- {% endfor %}
- {% endif %}
- <td><input type="submit" class="btn btn-primary" value="OK" /></td>
+ <td><input type="submit" class="btn btn-primary" value="OK" />
+ <textarea name="comment" class="input-xlarge" placeholder="Commentaire"></textarea></td>
</tr>
</form>
{% endif %}
- </tbody>
- <tfoot>
- {% if vote.is_transparent %}
+ </thead>
+
+ {% if not vote['is_anonymous'] %}
+ <tbody>
+ {% for user in users %}
+ {% if vote.is_transparent or (session.user and user.userid == session.user.id )%}
<tr>
- <td style="text-align: right">Somme</td>
+ <th>{% if 'user' in session and user.userid == session.user.id %}<i class="icon-user"></i>{% endif %} {{ user.username }}</th>
{% for choice in choices %}
- <td>nb</td>
+ <td class="{{user.choices[choice.id].class}}"><span>{{ user.choices[choice.id].name }}</span></td>
{% endfor %}
- <td></td>
+ {% if 'user' in session and (can_vote or (not vote['is_terminated'] and not vote['is_anonymous'])) %}
+ <td class="ok">{% if user.userid == session.user.id %}
+ <a href="#delete" data-toggle="modal" class="btn btn-danger btn-mini" title="Supprimer"><i class="icon-remove icon-white"></i></a>
+ <div class="modal hide fade" id="delete">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal">×</button>
+ <h3>Suppression de votre vote</h3>
+ </div>
+ <div class="modal-body">
+ <p>Voulez-vous vraiment supprimer votre vote ?</p>
+ </div>
+ <div class="modal-footer">
+ <a href="{{ url_for('vote_deletechoices', idvote=vote.id, iduser=session.user.id) }}" class="btn btn-danger">Confirmer</a>
+ <a href="#" class="btn" data-dismiss="modal">Annuler</a>
+ </div>
+ </div>
+ {% endif %}
+ <span class="comment">{% if user.comment %}{{user.comment}}{%endif%}</span>
+ </td>
+ {% else %}
+ <td class="ok">
+ <span class="comment">{% if user.comment %}{{user.comment}}{%endif%}</span>
+ </td>
+ {% endif %}
</tr>
{% endif %}
- </tfoot>
+ {% endfor %}
+ </tbody>
+ {% endif %}
</table>
+{% else %}
+{% if not can_vote %}
+<div class="alert alert-info">Vous avez déjà voté.</div>
+{% endif %}
+{% endif %}
</div>
-<div class="span3">
-<h3>Informations</h3>
-<dl class="dl-horizontal">
- <dt>Publié par <dd><code>maethor</code>
- <dt>Début le <dd><code>{{ vote.date_begin }}</code>
- <dt>Deadline le <dd><code>{{ vote.date_end }}</code>
- <dt>Groupe <dd><code>{{ vote.rolename }}</code>
- <dt>Catégorie <dd><code>{{ vote.category }}</code>
-</dl>
-<dl>
- <dt>Description : <dd>{{ vote.description }}
- <dt>Documents :<dd>
- <ul>
- {% for attachment in attachments %}
- <li><a href="{{ attachment.url }}">{{ attachment.url }}</a></li>
- {% endfor %}
- </ul>
- </li>
-</dl>
-</div>
+{% if vote.is_anonymous %}
+<div class="span9">
+ <h2 class='page-header'>Commentaires</h2>
+ <table class="table table-condensed table-bordered table-comments">
+ <tbody>
+ {% for user in users %}
+ <tr><td><span class="comment">{% if user.comment %}{{user.comment}}{%endif%}</span></td></tr>
+ {% endfor %}
+ </tbody>
+ </table>
+{% endif %}
</div>
{% endblock %}