PCv5/app/templates/widgets/poll.html

41 lines
1.3 KiB
HTML
Raw Normal View History

2021-02-19 23:26:10 +01:00
{% macro wpoll(poll) %}
2021-02-19 22:07:31 +01:00
2021-02-19 23:26:10 +01:00
{% import "widgets/polls/"+poll.template as poll_template with context %}
2021-02-19 22:07:31 +01:00
<div class="poll">
2021-02-19 23:26:10 +01:00
<h3>{{ poll.title }}</h3>
2021-02-19 22:07:31 +01:00
{# Poll has not begin #}
2021-02-19 23:26:10 +01:00
{% if not poll.started %}
<p><i>Le sondage ouvrira le {{ poll.start | date }}.</i></p>
2021-02-19 22:07:31 +01:00
{# Poll has ended: display results #}
2021-02-19 23:26:10 +01:00
{% elif poll.ended %}
{{ poll_template.results(poll) }}
<p><i>Ce sondage est terminé.</i></p>
2021-02-19 22:07:31 +01:00
{# Current user is a guest #}
{% elif not current_user.is_authenticated %}
<p><i>Seuls les membres peuvent voter.</i></p>
2021-02-19 22:07:31 +01:00
{# Current user cannot vote #}
2021-02-19 23:26:10 +01:00
{% elif not poll.can_vote(current_user) %}
<p><i>Vous n'avez pas le droit de voter dans ce sondage.</i></p>
2021-02-19 22:07:31 +01:00
{# Current user has already voted #}
2021-02-19 23:26:10 +01:00
{% elif poll.has_voted(current_user) %}
{{ poll_template.results(poll) }}
<p><i>Vous avez déjà voté.</i></p>
2021-02-19 22:07:31 +01:00
{# Current user can vote #}
{% else %}
<form class="poll" action="{{ url_for('poll_vote', poll_id=poll.id) }}" method="post" enctype="multipart/form-data">
2021-02-19 23:26:10 +01:00
{{ poll_template.choices(poll) }}
<input type="submit" value="Envoyer" />
<input id="csrf_token" name="csrf_token" type="hidden" value="{{ csrf_token() }}" />
2021-02-19 22:07:31 +01:00
</form>
{% endif %}
</div>
{% endmacro %}
2021-02-20 17:17:33 +01:00
{{ wpoll(poll) if poll }}