diff --git a/elections/migrations/0030_timestamps.py b/elections/migrations/0030_timestamps.py new file mode 100644 index 0000000..0149f46 --- /dev/null +++ b/elections/migrations/0030_timestamps.py @@ -0,0 +1,27 @@ +# Generated by Django 3.2.4 on 2021-06-28 20:03 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("elections", "0029_alter_election_visible"), + ] + + operations = [ + migrations.AddField( + model_name="election", + name="time_published", + field=models.DateTimeField( + default=None, null=True, verbose_name="date de publication" + ), + ), + migrations.AddField( + model_name="election", + name="time_tallied", + field=models.DateTimeField( + default=None, null=True, verbose_name="date du dépouillement" + ), + ), + ] diff --git a/elections/models.py b/elections/models.py index 25088e2..0fb2b79 100644 --- a/elections/models.py +++ b/elections/models.py @@ -72,6 +72,13 @@ class Election(models.Model): archived = models.BooleanField(_("archivée"), default=False) + time_tallied = models.DateTimeField( + _("date du dépouillement"), null=True, default=None + ) + time_published = models.DateTimeField( + _("date de publication"), null=True, default=None + ) + class Meta: permissions = [ ("is_admin", _("Peut administrer des élections")), diff --git a/elections/templates/elections/election.html b/elections/templates/elections/election.html index 0ce7c44..1d74332 100644 --- a/elections/templates/elections/election.html +++ b/elections/templates/elections/election.html @@ -4,15 +4,15 @@ {% block content %} -
+
{# Titre de l'élection #}

{{ election.name }}

-
+
{# Liste des votant·e·s #} -
+
@@ -23,7 +23,7 @@ {# Liste des bulletins #} {% if election.results_public %} -
+
@@ -35,7 +35,7 @@ {% if election.start_date < current_time %} {# Statut de l'élection #} -
+
{% if election.end_date < current_time %} {% trans "Élection terminée" %} @@ -48,7 +48,7 @@ {# Lien vers la page d'administration #} {% if election.created_by == user %} - -
+
{# Dates d'ouverture de l'élection #} -
-
+
+
{{ election.start_date|date:"d/m/Y H:i" }} @@ -75,7 +75,7 @@
{# Créateurice de l'élection #} -
+
{% blocktrans with creator=election.created_by.full_name %}Créé par {{ creator }}{% endblocktrans %}
@@ -96,6 +96,28 @@
{% endif %}
+ +
+
+ {# Date du dépouillement #} + {% if election.time_tallied %} +
+ + {% blocktrans with timestamp=election.time_tallied|date:"d/m/Y H:i" %}Dépouillé le {{ timestamp }}{% endblocktrans %} + +
+ {% endif %} + + {# Date de la publication #} + {% if election.time_published %} +
+ + {% blocktrans with timestamp=election.time_published|date:"d/m/Y H:i" %}Publié le {{ timestamp }}{% endblocktrans %} + +
+ {% endif %} +
+

{# Précisions sur les modalités de vote #} diff --git a/elections/templates/elections/election_list.html b/elections/templates/elections/election_list.html index 12ea109..9c54dde 100644 --- a/elections/templates/elections/election_list.html +++ b/elections/templates/elections/election_list.html @@ -60,23 +60,6 @@
{% endif %} - {% if e.tallied %} -
- {% trans "Élection dépouillée" %} -
- {% endif %} - - {% if e.results_public %} -
- {% trans "Élection publiée" %} -
- {% endif %} - - {% if e.archived %} -
- {% trans "Élection archivée" %} -
- {% endif %} {% if e.created_by == user %}
@@ -91,6 +74,38 @@
+ {% if e.tallied or e.results_public or e.archived %} +
+
+
+ {% if e.tallied %} + + {% if e.time_tallied %} + {% blocktrans with timestamp=e.time_tallied|date:"d/m/Y H:i" %}Élection dépouillée le {{ timestamp }}{% endblocktrans %} + {% else %} + {% trans "Élection dépouillée" %} + {% endif %} + + {% endif %} + + {% if e.results_public %} + + {% if e.time_published %} + {% blocktrans with timestamp=e.time_published|date:"d/m/Y H:i" %}Élection publiée le {{ timestamp }}{% endblocktrans %} + {% else %} + {% trans "Élection publiée" %} + {% endif %} + + {% endif %} + + {% if e.archived %} + {% trans "Élection archivée" %} + {% endif %} +
+
+
+ {% endif %} + {% if e.description %}
diff --git a/elections/views.py b/elections/views.py index ea8704a..1b05d1c 100644 --- a/elections/views.py +++ b/elections/views.py @@ -289,6 +289,7 @@ class ElectionTallyView(ClosedElectionMixin, BackgroundUpdateView): q.tally() election.tallied = True + election.time_tallied = timezone.now() election.save() return super().get(request, *args, **kwargs) @@ -305,6 +306,10 @@ class ElectionChangePublicationView(ClosedElectionMixin, BackgroundUpdateView): def get(self, request, *args, **kwargs): self.election = self.get_object() self.election.results_public = not self.election.results_public + self.election.time_published = ( + timezone.now() if self.election.results_public else None + ) + self.election.save() return super().get(request, *args, **kwargs) diff --git a/shared/locale/en/LC_MESSAGES/django.mo b/shared/locale/en/LC_MESSAGES/django.mo index 1532d08..50dfdfc 100644 Binary files a/shared/locale/en/LC_MESSAGES/django.mo and b/shared/locale/en/LC_MESSAGES/django.mo differ diff --git a/shared/locale/en/LC_MESSAGES/django.po b/shared/locale/en/LC_MESSAGES/django.po index f7e08e5..36e6ca1 100644 --- a/shared/locale/en/LC_MESSAGES/django.po +++ b/shared/locale/en/LC_MESSAGES/django.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-06-28 21:29+0200\n" -"PO-Revision-Date: 2021-06-28 21:30+0200\n" +"POT-Creation-Date: 2021-06-28 22:41+0200\n" +"PO-Revision-Date: 2021-06-28 22:43+0200\n" "Last-Translator: Test Translator \n" "Language-Team: \n" "Language: en\n" @@ -120,51 +120,59 @@ msgstr "counted" msgid "archivée" msgstr "archived" -#: elections/models.py:77 +#: elections/models.py:76 +msgid "date du dépouillement" +msgstr "date of count" + +#: elections/models.py:79 +msgid "date de publication" +msgstr "date of publication" + +#: elections/models.py:84 msgid "Peut administrer des élections" msgstr "Can manage elections" -#: elections/models.py:87 +#: elections/models.py:94 msgid "question" msgstr "question" -#: elections/models.py:90 +#: elections/models.py:97 msgid "type de question" msgstr "type of question" -#: elections/models.py:97 +#: elections/models.py:104 msgid "nombre maximal de votes reçus" msgstr "maximal number of votes received" -#: elections/models.py:154 +#: elections/models.py:161 msgid "texte" msgstr "text" -#: elections/models.py:155 +#: elections/models.py:162 msgid "abréviation" msgstr "abbreviation" -#: elections/models.py:157 +#: elections/models.py:164 msgid "option gagnante" msgstr "winning option" -#: elections/models.py:165 +#: elections/models.py:172 msgid "nombre de votes reçus" msgstr "number of votes received" -#: elections/models.py:195 +#: elections/models.py:202 msgid "rang de l'option" msgstr "option's ranking" -#: elections/models.py:211 +#: elections/models.py:218 msgid "votes supplémentaires" msgstr "extra votes" -#: elections/models.py:227 +#: elections/models.py:234 msgid "Nom et Prénom" msgstr "Name and surname" -#: elections/models.py:250 elections/tests/test_models.py:57 +#: elections/models.py:257 elections/tests/test_models.py:57 msgid "identifiants spécifiques" msgstr "dedicated credentials" @@ -241,7 +249,7 @@ msgid "Élection en cours" msgstr "Election in progress" #: elections/templates/elections/election.html:52 -#: elections/templates/elections/election_list.html:83 +#: elections/templates/elections/election_list.html:66 msgid "Administrer" msgstr "Manage" @@ -254,11 +262,21 @@ msgstr "Created by %(creator)s" msgid "Votre vote a bien été enregistré." msgstr "Your vote has been recorded." -#: elections/templates/elections/election.html:119 +#: elections/templates/elections/election.html:106 +#, python-format +msgid "Dépouillé le %(timestamp)s" +msgstr "Counted on %(timestamp)s" + +#: elections/templates/elections/election.html:115 +#, python-format +msgid "Publié le %(timestamp)s" +msgstr "Published on %(timestamp)s" + +#: elections/templates/elections/election.html:141 msgid "Voter" msgstr "Vote" -#: elections/templates/elections/election.html:130 +#: elections/templates/elections/election.html:152 msgid "" "Pour voter lors de cette élection, vous devez vous connecter à l'aide des " "identifiants reçus par mail." @@ -266,7 +284,7 @@ msgstr "" "To vote in this election, you must log in using the login credentials you " "received by e-mail." -#: elections/templates/elections/election.html:132 +#: elections/templates/elections/election.html:154 #: elections/templates/elections/election_voters.html:65 msgid "" "Pour voter lors de cette élection, vous devez vous connecter à l'aide du CAS " @@ -277,16 +295,16 @@ msgstr "" "restrictions may apply and your vote may be deleted if you are not eligible " "to vote." -#: elections/templates/elections/election.html:148 +#: elections/templates/elections/election.html:170 msgid "Connexion par identifiants" msgstr "Login with credentials" -#: elections/templates/elections/election.html:159 +#: elections/templates/elections/election.html:181 #: shared/templates/authens/login_switch.html:20 msgid "Connexion via CAS" msgstr "Login via CAS" -#: elections/templates/elections/election.html:194 +#: elections/templates/elections/election.html:216 msgid "A voté" msgstr "Voted" @@ -399,15 +417,25 @@ msgstr "List of elections" msgid "Créer une élection" msgstr "Create an election" -#: elections/templates/elections/election_list.html:65 +#: elections/templates/elections/election_list.html:84 +#, python-format +msgid "Élection dépouillée le %(timestamp)s" +msgstr "Election counted on %(timestamp)s" + +#: elections/templates/elections/election_list.html:86 msgid "Élection dépouillée" msgstr "Election counted" -#: elections/templates/elections/election_list.html:71 +#: elections/templates/elections/election_list.html:94 +#, python-format +msgid "Élection publiée le %(timestamp)s" +msgstr "Election published on %(timestamp)s" + +#: elections/templates/elections/election_list.html:96 msgid "Élection publiée" msgstr "Published election" -#: elections/templates/elections/election_list.html:77 +#: elections/templates/elections/election_list.html:102 msgid "Élection archivée" msgstr "Archived election" @@ -643,35 +671,35 @@ msgstr "Election successfully modified!" msgid "Élection dépouillée avec succès !" msgstr "Election successfully counted!" -#: elections/views.py:302 +#: elections/views.py:303 msgid "Élection publiée avec succès !" msgstr "Election successfully published!" -#: elections/views.py:303 +#: elections/views.py:304 msgid "Élection dépubliée avec succès !" msgstr "Election successfully de-published!" -#: elections/views.py:330 +#: elections/views.py:335 msgid "Élection archivée avec succès !" msgstr "Election successfully archived!" -#: elections/views.py:362 +#: elections/views.py:367 msgid "Question modifiée avec succès !" msgstr "Question successfully modified!" -#: elections/views.py:374 +#: elections/views.py:379 msgid "Question supprimée !" msgstr "Question deleted!" -#: elections/views.py:412 +#: elections/views.py:417 msgid "Option modifiée avec succès !" msgstr "Option successfully modified!" -#: elections/views.py:424 +#: elections/views.py:429 msgid "Option supprimée !" msgstr "Option deleted!" -#: elections/views.py:578 +#: elections/views.py:583 msgid "Votre choix a bien été enregistré !" msgstr "Your choice has been recorded!"