{% macro wpoll(poll) %} {% set n_answers = len(poll.answers) %} {% import "widgets/polls/"+poll.template as poll_template with context %}

{{ poll.title }}

{# Poll has not begin #} {% if not poll.started %}

Le sondage ouvrira le {{ poll.start | date }}.

{# Poll has ended: display results #} {% elif poll.ended %}
Ce sondage est terminé. Voici les résultats des {{ n_answers }} participation{{ n_answers | pluralize }}.
{{ poll_template.results(poll) }} {# Current user is a guest #} {% elif not current_user.is_authenticated %}

Seuls les membres peuvent voter

{# Current user cannot vote #} {% elif not poll.can_vote(current_user) %}

Vous n'avez pas le droit de voter dans ce sondage. Désolé…

{# Current user has already voted #} {% elif poll.has_voted(current_user) %}

Vous avez déjà voté. Revenez le {{ poll.end | date }} pour voir les résultats

{# Current user can vote #} {% else %}
{{ poll_template.choices(poll) }}
{% endif %}
{% endmacro %} {{ wpoll(poll) if poll }}