polls: updated templates
This commit is contained in:
parent
169aca8304
commit
ec3f33ead0
|
@ -1,34 +1,36 @@
|
|||
{% macro wpoll(p) %}
|
||||
{% macro wpoll(poll) %}
|
||||
|
||||
{% import "widgets/polls/"+p.template as poll_template with context %}
|
||||
{% set n_answers = len(poll.answers) %}
|
||||
|
||||
{% import "widgets/polls/"+poll.template as poll_template with context %}
|
||||
|
||||
<div class="poll">
|
||||
<h3>{{ p.title }}</h3>
|
||||
<h3>{{ poll.title }}</h3>
|
||||
{# Poll has not begin #}
|
||||
{% if not p.started %}
|
||||
<p><i>Le sondage ouvrira le {{ p.start | date }}.</i></p>
|
||||
{% if not poll.started %}
|
||||
<p><i>Le sondage ouvrira le {{ poll.start | date }}.</i></p>
|
||||
|
||||
{# Poll has ended: display results #}
|
||||
{% elif p.ended %}
|
||||
<div>Ce sondage est terminé. Voici les résultats.</div>
|
||||
{{ poll_template.results(p) }}
|
||||
{% elif poll.ended %}
|
||||
<div>Ce sondage est terminé. Voici les résultats des {{ n_answers }} participation{{ n_answers | pluralize }}.</div>
|
||||
{{ poll_template.results(poll) }}
|
||||
|
||||
{# Current user is a guest #}
|
||||
{% elif not current_user.is_authenticated %}
|
||||
<p><i>Seuls les membres peuvent voter</i></p>
|
||||
|
||||
{# Current user cannot vote #}
|
||||
{% elif not p.can_vote(current_user) %}
|
||||
{% elif not poll.can_vote(current_user) %}
|
||||
<p><i>Vous n'avez pas le droit de voter dans ce sondage. Désolé…</i></p>
|
||||
|
||||
{# Current user has already voted #}
|
||||
{% elif p.has_voted(current_user) %}
|
||||
<p><i>Vous avez déjà voté. Revenez le {{ p.ended | date }} pour voir les résultats</i></p>
|
||||
{% elif poll.has_voted(current_user) %}
|
||||
<p><i>Vous avez déjà voté. Revenez le {{ poll.ended | date }} pour voir les résultats</i></p>
|
||||
|
||||
{# Current user can vote #}
|
||||
{% else %}
|
||||
<form class="poll" action="/poll/{{ p.id }}" method="post" enctype="multipart/form-data">
|
||||
{{ poll_template.choices(p) }}
|
||||
<form class="poll" action="/poll/{{ poll.id }}" method="post" enctype="multipart/form-data">
|
||||
{{ poll_template.choices(poll) }}
|
||||
<input type="submit" value="Envoyer">
|
||||
<input id="csrf_token" name="csrf_token" type="hidden" value="{{ csrf_token() }}">
|
||||
</form>
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
<tr>
|
||||
<td><label for="{{ poll.id }}-{{ choice.id }}">{{ choice.title }}</label></td>
|
||||
<td>
|
||||
<progress id="{{ poll.id }}-{{ choice.id }}" value="{{ votes }}" max="{{ len(poll.answers) }}">
|
||||
{{ votes / len(poll.answers) if len(poll.answers) else 0 }} % ({{ votes }})
|
||||
<progress id="{{ poll.id }}-{{ choice.id }}" value="{{ votes }}" max="{{ n_answers }}">
|
||||
{{ votes / n_answers if n_answers else 0 }} % ({{ votes }})
|
||||
</progress>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
Loading…
Reference in New Issue