284 lines
8.9 KiB
HTML
284 lines
8.9 KiB
HTML
{% extends "base.html" %}
|
|
{% load i18n %}
|
|
|
|
|
|
{% block extra_head %}
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
var $modalButtons = document.querySelectorAll('.modal-button') || [];
|
|
|
|
$modalButtons.forEach(function($el) {
|
|
$el.addEventListener('click', function() {
|
|
var $target = document.getElementById($el.dataset.target);
|
|
$target_form = $target.querySelector("form");
|
|
$target_form.action = $el.dataset.post_url;
|
|
});
|
|
});
|
|
});
|
|
|
|
</script>
|
|
{% endblock %}
|
|
|
|
|
|
{% block content %}
|
|
|
|
<div class="level is-block-tablet is-block-desktop is-flex-fullhd">
|
|
{# Titre de l'élection #}
|
|
<div class="level-left is-flex-shrink-1">
|
|
<h1 class="title">{{ election.name }}</h1>
|
|
</div>
|
|
|
|
<div class="level-right">
|
|
<div class="level-item">
|
|
<div class="dropdown is-right">
|
|
<div class="dropdown-trigger">
|
|
<button class="button" aria-haspopup="true" aria-controls="dropdown-menu">
|
|
<span class="icon-text">
|
|
<span class="icon">
|
|
<i class="fas fa-cog" aria-hidden="true"></i>
|
|
</span>
|
|
<span>{% trans "Actions" %}</span>
|
|
</span>
|
|
</button>
|
|
</div>
|
|
|
|
<div class="dropdown-menu" id="dropdown-menu" role="menu">
|
|
<div class="dropdown-content">
|
|
{# Téléchargement de la liste des votant·e·s #}
|
|
<a class="dropdown-item" href="{% url 'election.export-voters' election.pk %}">
|
|
<span class="icon">
|
|
<i class="fas fa-file-download"></i>
|
|
</span>
|
|
<span>{% trans "Exporter les votant·e·s" %}
|
|
</a>
|
|
|
|
{% if election.start_date > current_time %}
|
|
{# Modification de l'élection #}
|
|
<a class="dropdown-item" href="{% url 'election.update' election.pk %}">
|
|
<span class="icon">
|
|
<i class="fas fa-edit"></i>
|
|
</span>
|
|
<span>{% trans "Modifier" %}</span>
|
|
</a>
|
|
|
|
{# Gestion des votant·e·s #}
|
|
{% if election.restricted %}
|
|
<a class="dropdown-item" href="{% url 'election.upload-voters' election.pk %}">
|
|
<span class="icon">
|
|
<i class="fas fa-file-import"></i>
|
|
</span>
|
|
<span>{% trans "Gestion de la liste de votant·e·s" %}</span>
|
|
</a>
|
|
{% endif %}
|
|
|
|
{% elif election.end_date < current_time %}
|
|
|
|
{% if not election.tallied %}
|
|
{# Liste des votants #}
|
|
<a class="dropdown-item" href="{% url 'election.voters' election.pk %}">
|
|
<span class="icon">
|
|
<i class="fas fa-list"></i>
|
|
</span>
|
|
<span>{% trans "Liste des votant·e·s" %}</span>
|
|
</a>
|
|
|
|
{# Dépouillement #}
|
|
<a class="dropdown-item" href="{% url 'election.tally' election.pk %}">
|
|
<span class="icon">
|
|
<i class="fas fa-poll-h"></i>
|
|
</span>
|
|
<span>{% trans "Dépouiller" %}</span>
|
|
</a>
|
|
|
|
{% else %}
|
|
|
|
{# Publication des résultats #}
|
|
{% if not election.archived %}
|
|
<a class="dropdown-item" href="{% url 'election.publish' election.pk %}">
|
|
<span class="icon">
|
|
<i class="fas fa-edit"></i>
|
|
</span>
|
|
{% if not election.results_public %}
|
|
<span>{% trans "Publier" %}</span>
|
|
{% else %}
|
|
<span>{% trans "Dépublier" %}</span>
|
|
{% endif %}
|
|
</a>
|
|
{% endif %}
|
|
|
|
{# Archivage #}
|
|
{% if not election.archived %}
|
|
<a class="dropdown-item" href="{% url 'election.archive' election.pk %}">
|
|
<span class="icon">
|
|
<i class="fas fa-archive"></i>
|
|
</span>
|
|
<span>{% trans "Archiver" %}</span>
|
|
</a>
|
|
{% endif %}
|
|
{% endif %}
|
|
|
|
{% endif %}
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</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>
|
|
</div>
|
|
</div>
|
|
<hr>
|
|
|
|
{# Description de l'élection #}
|
|
{% if election.description %}
|
|
<div class="message is-primary">
|
|
<div class="message-body">{{ election.description|linebreaksbr }}</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{# Précisions sur les modalités de vote #}
|
|
{% if election.vote_restrictions %}
|
|
<div class="message is-warning">
|
|
<div class="message-body">{{ election.vote_restrictions|linebreaksbr }}</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">
|
|
<div class="level-item is-flex-shrink-1">
|
|
<span>{{ q }}</span>
|
|
</div>
|
|
|
|
{% if election.start_date > current_time %}
|
|
<div class="level-item">
|
|
<a class="tag is-outlined is-light is-danger" href="{% url 'election.del-question' q.pk %}">
|
|
<span class="icon-text">
|
|
<span class="icon">
|
|
<i class="fas fa-times"></i>
|
|
</span>
|
|
<span>{% trans "Supprimer" %}</span>
|
|
</span>
|
|
</a>
|
|
|
|
<a class="tag is-outlined is-light is-info ml-1" href="{% url 'election.mod-question' q.pk %}">
|
|
<span class="icon-text">
|
|
<span class="icon">
|
|
<i class="fas fa-edit"></i>
|
|
</span>
|
|
<span>{% trans "Modifier" %}</span>
|
|
</span>
|
|
</a>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<div class="level-right">
|
|
<span class="tag is-outlined is-primary is-light">{{ q.get_type_display }}</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{# Liste des options possibles #}
|
|
{% for o in q.options.all %}
|
|
<div class="panel-block">
|
|
{% if election.start_date > current_time %}
|
|
<span class="tags has-addons mb-0">
|
|
<a class="tag is-danger is-light is-outlined has-tooltip-primary mb-0" data-tooltip="{% trans "Supprimer" %}" href="{% url 'election.del-option' o.pk %}">
|
|
<span class="icon">
|
|
<i class="fas fa-times"></i>
|
|
</span>
|
|
</a>
|
|
<a class="tag is-info is-light is-outlined has-tooltip-primary mb-0" data-tooltip="{% trans "Modifier" %}" href="{% url 'election.mod-option' o.pk %}">
|
|
<span class="icon">
|
|
<i class="fas fa-edit"></i>
|
|
</span>
|
|
</a>
|
|
</span>
|
|
|
|
{% elif election.tallied %}
|
|
<span class="tag {% if o.winner %}is-success{% else %}is-primary{% endif %}">
|
|
<span class="icon-text">
|
|
{% 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>
|
|
|
|
<span class="ml-2">{{ o }}</span>
|
|
</div>
|
|
{% endfor %}
|
|
|
|
{# Affiche plus d'informations sur le résultat #}
|
|
{% if election.tallied %}
|
|
{{ q.get_results_data }}
|
|
{% endif %}
|
|
|
|
{# Rajout d'une option #}
|
|
{% if election.start_date > current_time %}
|
|
<div class="panel-block">
|
|
<button class="button modal-button is-primary is-outlined is-fullwidth" data-post_url="{% url 'election.add-option' q.pk %}" data-target="modal-add_option">
|
|
<span class="icon">
|
|
<i class="fas fa-plus"></i>
|
|
</span>
|
|
<span>{% trans "Rajouter une option" %}</span>
|
|
</button>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
{% endfor %}
|
|
|
|
{# Rajout d'une question #}
|
|
{% if election.start_date > current_time %}
|
|
|
|
{# Rajout d'une option #}
|
|
{% trans "Rajouter une option" as modal_title %}
|
|
{% include "forms/modal-form.html" with modal_id="add_option" form=o_form %}
|
|
|
|
{# Rajout d'une question #}
|
|
{% trans "Rajouter une question" as modal_title %}
|
|
{% include "forms/modal-form.html" with modal_id="add_question" form=q_form %}
|
|
|
|
|
|
<div class="columns is-centered" id="q_add">
|
|
<div class="column is-two-thirds">
|
|
<button class="button modal-button is-primary is-outlined is-fullwidth" data-post_url="{% url 'election.add-question' election.pk %}" data-target="modal-add_question">
|
|
<span class="icon">
|
|
<i class="fas fa-question"></i>
|
|
</span>
|
|
<span>{% trans "Rajouter une question" %}</span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% endblock %}
|