kadenios/elections/templates/elections/election.html

232 lines
7 KiB
HTML

{% extends "base.html" %}
{% load i18n markdown %}
{% block content %}
<div class="level">
{# Titre de l'élection #}
<div class="level-left is-flex-shrink-1">
<h1 class="title">{{ election.name }}</h1>
</div>
<div class="level-right">
{# Liste des votant·e·s #}
<div class="level-item">
<a class="button is-primary is-light is-outlined" href="{% url 'election.voters' election.pk %}">
<span class="icon">
<i class="fas fa-clipboard-list"></i>
</span>
<span>{% trans "Votant·e·s" %}</span>
</a>
</div>
{# Liste des bulletins #}
{% if election.results_public %}
<div class="level-item">
<a class="button is-primary is-light is-outlined" href="{% url 'election.ballots' election.pk %}">
<span class="icon">
<i class="fas fa-list"></i>
</span>
<span>{% trans "Bulletins" %}</span>
</a>
</div>
{% endif %}
{% if election.start_date < current_time %}
{# Statut de l'élection #}
<div class="level-item">
<span class="tag is-medium is-outlined is-light is-primary">
{% if election.end_date < current_time %}
{% trans "Élection terminée" %}
{% else %}
{% trans "Élection en cours" %}
{% endif %}
</span>
</div>
{% endif %}
{# Lien vers la page d'administration #}
{% if election.created_by == user %}
<div class="level-item">
<a class="button has-tooltip-primary" href="{% url 'election.admin' election.pk %}" data-tooltip="{% trans "Administrer" %}">
<span class="icon">
<i class="fas fa-cog"></i>
</span>
</a>
</div>
{% endif %}
</div>
</div>
<div class="level">
{# Dates d'ouverture de l'élection #}
<div class="level-left">
<div class="level-item">
<span class="tag is-medium is-primary">
<span class="icon-text">
<span>{{ election.start_date|date:"d/m/Y H:i" }}</span>
<span class="icon">
<i class="fas fa-long-arrow-alt-right"></i>
</span>
<span>{{ election.end_date|date:"d/m/Y H:i" }}</span>
</span>
</span>
</div>
{# Créateurice de l'élection #}
<div class="level-item">
<span class="tag is-primary is-light is-outlined">{% blocktrans with creator=election.created_by.full_name %}Créé par {{ creator }}{% endblocktrans %}</span>
</div>
</div>
{# Confirmation de vote #}
{% if has_voted %}
<div class="level-right">
<div class="level-item">
<div class="tag is-medium is-outlined is-success is-light">
<span class="icon-text">
<span class="icon">
<i class="fas fa-check"></i>
</span>
<span>{% trans "Votre vote a bien été enregistré." %}</span>
</span>
</div>
</div>
</div>
{% endif %}
</div>
<hr>
{# Précisions sur les modalités de vote #}
{% if election.vote_restrictions %}
<div class="message is-warning">
<div class="message-body content">{{ election.vote_restrictions|markdown|safe }}</div>
</div>
{% endif %}
{# Indications de connexion #}
{% if election.start_date < current_time and election.end_date > current_time %}
{% if can_vote %}
<div class="columns is-centered tile is-ancestor">
<div class="column is-one-third tile is-parent">
<a class="tile is-child notification is-primary" href="{% url 'election.vote' election.questions.first.pk %}">
<div class="subtitle has-text-centered">
<span class="icon-text">
<span class="icon has-text-white">
<i class="fas fa-vote-yea"></i>
</span>
<span class="ml-3">{% trans "Voter" %}</span>
</span>
</div>
</a>
</div>
</div>
{% else %}
<div class="message is-warning">
<div class="message-body">
{% if election.restricted %}
{% trans "Pour voter lors de cette élection, vous devez vous connecter à l'aide des identifiants reçus par mail." %}
{% else %}
{% trans "Pour voter lors de cette élection, vous devez vous connecter à l'aide du CAS élève, d'autres restrictions peuvent s'appliquer et votre vote pourra être supprimé si vous n'avez pas le droit de vote." %}
{% endif %}
</div>
</div>
<div class="columns is-centered">
<div class="column is-half">
<div class="tile is-ancestor">
<div class="tile is-parent">
{% if election.restricted %}
<a class="tile is-child notification is-primary" href="{% url 'auth.election' election.pk %}?next={% url 'election.view' election.pk %}">
<div class="subtitle has-text-centered mb-2">
<span class="icon-text">
<span class="icon has-text-white">
<i class="fas fa-unlock"></i>
</span>
<span class="ml-3">{% trans "Connexion par identifiants" %}</span>
</span>
</div>
</a>
{% else %}
<a class="tile is-child notification is-primary" href="{% url 'authens:login.cas' %}">
<div class="subtitle has-text-centered mb-2">
<span class="icon-text">
<span class="icon has-text-white">
<i class="fas fa-school"></i>
</span>
<span class="ml-3">{% trans "Connexion via CAS" %}</span>
</span>
</div>
</a>
{% endif %}
</div>
</div>
</div>
</div>
{% endif %}
{% endif %}
{# Description de l'élection #}
{% if election.description %}
<div class="message is-primary">
<div class="message-body content">{{ election.description|markdown|safe }}</div>
</div>
{% endif %}
{# Liste des questions #}
{% for q in election.questions.all %}
<div class="panel" id="q_{{ q.pk }}">
<div class="panel-heading is-size-6">
<div class="level">
<div class="level-left is-flex-shrink-1">
<span class="icon-text">
<span class="icon">
<i class="fas fa-poll-h"></i>
</span>
<span>{{ q }}</span>
</span>
</div>
{% if q in cast_questions %}
<div class="level-right">
<span class="tag is-outlined is-light is-success">{% trans "A voté" %}</span>
</div>
{% endif %}
</div>
</div>
{# Liste des options possibles #}
{% for o in q.options.all %}
<div class="panel-block">
{% if election.tallied and election.results_public %}
<span class="tag {% if o.winner %}is-success{% else %}is-primary{% endif %}">
{% if q.vote_type == "select" %}
<span class="icon">
<i class="fas fa-vote-yea"></i>
</span>
<span>{{ o.nb_votes }}</span>
{% elif q.vote_type == "rank" %}
<span class="icon">
<i class="fas fa-layer-group"></i>
</span>
<span>{% if o.abbreviation %}{{ o.abbreviation }}{% else %}{{ forloop.counter }}{% endif %}</span>
{% endif %}
</span>
{% endif %}
<span class="ml-2">{{ o }}</span>
</div>
{% endfor %}
{# Affiche plus d'informations sur le résultat #}
{% if election.tallied and election.results_public %}
{{ q.get_results_data }}
{% endif %}
</div>
{% endfor %}
{% endblock %}