PCv5/app/templates/widgets/poll.html

41 lines
1.3 KiB
HTML

{% macro wpoll(poll) %}
{% import "widgets/polls/"+poll.template as poll_template with context %}
<div class="poll">
<h3>{{ poll.title }}</h3>
{# Poll has not begin #}
{% if not poll.started %}
<p><i>Le sondage ouvrira le {{ poll.start | date }}.</i></p>
{# Poll has ended: display results #}
{% elif poll.ended %}
{{ poll_template.results(poll) }}
<p><i>Ce sondage est terminé.</i></p>
{# 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 poll.can_vote(current_user) %}
<p><i>Vous n'avez pas le droit de voter dans ce sondage.</i></p>
{# Current user has already voted #}
{% elif poll.has_voted(current_user) %}
{{ poll_template.results(poll) }}
<p><i>Vous avez déjà voté.</i></p>
{# Current user can vote #}
{% else %}
<form class="poll" action="{{ url_for('poll_vote', poll_id=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>
{% endif %}
</div>
{% endmacro %}
{{ wpoll(poll) if poll }}