From 3601508ab2b901e28b91731ae5c5124cdca226e1 Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Mon, 28 Jun 2021 21:33:07 +0200 Subject: [PATCH] =?UTF-8?q?On=20affiche=20l'abr=C3=A9viation=20dans=20le?= =?UTF-8?q?=20tableu=20des=20r=C3=A9sultats?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- elections/models.py | 3 ++ .../templates/elections/results/rank.html | 4 +- elections/utils.py | 14 ++++-- shared/locale/en/LC_MESSAGES/django.mo | Bin 15821 -> 15823 bytes shared/locale/en/LC_MESSAGES/django.po | 47 +++++++++--------- 5 files changed, 37 insertions(+), 31 deletions(-) diff --git a/elections/models.py b/elections/models.py index cdc02e2..25088e2 100644 --- a/elections/models.py +++ b/elections/models.py @@ -170,6 +170,9 @@ class Option(models.Model): super().save(*args, **kwargs) + def get_abbr(self, default): + return self.abbreviation or default + def __str__(self): if self.abbreviation: return self.abbreviation + " - " + self.text diff --git a/elections/templates/elections/results/rank.html b/elections/templates/elections/results/rank.html index 96e7141..d6bab93 100644 --- a/elections/templates/elections/results/rank.html +++ b/elections/templates/elections/results/rank.html @@ -24,7 +24,6 @@ {% for line, o in matrix %} - {% with loser=forloop.counter %} @@ -36,10 +35,9 @@ {% for cell, class in line %} - {{ cell }} + {{ cell.value }} {% endfor %} - {% endwith %} {% endfor %} diff --git a/elections/utils.py b/elections/utils.py index 90633e2..aec42f5 100644 --- a/elections/utils.py +++ b/elections/utils.py @@ -238,18 +238,22 @@ class ResultsData: options = list(question.options.all()) n = len(options) - _matrix = np.zeros((n, n), dtype=int) - matrix = np.zeros((n, n), dtype=tuple) + _matrix = np.full((n, n), {"value": 0}, dtype=dict) + matrix = np.empty((n, n), dtype=tuple) for d in duels: i, j = options.index(d.loser), options.index(d.winner) - _matrix[i, j] = d.amount + _matrix[i, j] = { + "value": d.amount, + "winner": d.winner.get_abbr(j + 1), + "loser": d.loser.get_abbr(i + 1), + } for i in range(n): for j in range(n): - if _matrix[i, j] > _matrix[j, i]: + if _matrix[i, j]["value"] > _matrix[j, i]["value"]: matrix[i, j] = (_matrix[i, j], "is-success") - elif _matrix[i, j] < _matrix[j, i]: + elif _matrix[i, j]["value"] < _matrix[j, i]["value"]: matrix[i, j] = (_matrix[i, j], "is-danger") else: matrix[i, j] = (_matrix[i, j], "") diff --git a/shared/locale/en/LC_MESSAGES/django.mo b/shared/locale/en/LC_MESSAGES/django.mo index e2a3e4ec84a5313165c8c63e9c597f1ace476c40..1532d08bad2d0afd21bd7a520d745c61086f058a 100644 GIT binary patch delta 2475 zcmXZdYfP499LMqhqjG%Ypr{nW>|F^%9& zE2Cz;aPtK^^o6sT1g@qsXthGwT+TL2ij_@zfl}XJ_qDO-b6+jD@G$Pe8!F-+h}skzCwBZ7_|Y7{T3IAeJAxEFbkG&!8gTj&I^# zjKIH80nZ|_SaQ0Ti83S^_BbkIEvWsvTszpyMSzY0%*JtCgZEGyu3kY9ScH^^RiiT0 zfSI@xGq4+VWG7Jf|A+~oC3Z;(%kedoq+t>OF?*=;(Ms$}x7 z>dr?MO(m)Zob`zd22Z1EX9AUxKQR(#a0q?b-UAM!GIcSV{Oe-O zb^L&Ok}Ie{W>Arb-0vCVOhj$G0u@*p>dU#wwckd)&i%Lt&!94!p5ql^7KYP)G{}Vp zp2A4Z@>yh0+resDu!o;Rcphu9Hka(+C&-#Mj{9*AtFbfBY(0LB3g9j(z<6$I#5~Mp zpFZrR9US2$-N8j&p_jt5xRCZWjKL|_p2Yy|@FK4mvrs86$4som#kj|fce?f=RLy*b z(Rd1#@nNK>gZ8bPa21u3Y1jS-HPK(}6;&+Gqn(B-z6@tJ>I+wh3ixSMAWf*^Y{wXE(!I- z*{JbST#6545^iz*`%vq3l#_o&cz_N)X&34Vdoh5=QK`L*x?vJy@fTFl-9a5$N`?2N zIjEv6K+Ri^3V0(bum;rp7SxgNuh{LS<_I0S;VkN(#AVc%YYKG~F%Ni0lYzRi#I@@% zK)c1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` zTvSmOqUM#M0=^d&SOaQ)3+l>uS3d5griTu_(1-dXF@*Z%8b@74V3l_@S*RCFT)PfK zv|C*J0BW5#P$xf)`u!N}el)((_g-&b{2`yux@!W1zSX_{gfV|)Q*&Ee@1H5(C&m`8 W2o)8rTwdIJE&J10ufMyXGVmXhu?OM+ diff --git a/shared/locale/en/LC_MESSAGES/django.po b/shared/locale/en/LC_MESSAGES/django.po index 768c34c..f7e08e5 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-18 22:33+0200\n" -"PO-Revision-Date: 2021-06-18 22:34+0200\n" +"POT-Creation-Date: 2021-06-28 21:29+0200\n" +"PO-Revision-Date: 2021-06-28 21:30+0200\n" "Last-Translator: Test Translator \n" "Language-Team: \n" "Language: en\n" @@ -152,19 +152,19 @@ msgstr "winning option" msgid "nombre de votes reçus" msgstr "number of votes received" -#: elections/models.py:192 +#: elections/models.py:195 msgid "rang de l'option" msgstr "option's ranking" -#: elections/models.py:208 +#: elections/models.py:211 msgid "votes supplémentaires" msgstr "extra votes" -#: elections/models.py:224 +#: elections/models.py:227 msgid "Nom et Prénom" msgstr "Name and surname" -#: elections/models.py:247 elections/tests/test_models.py:57 +#: elections/models.py:250 elections/tests/test_models.py:57 msgid "identifiants spécifiques" msgstr "dedicated credentials" @@ -470,14 +470,15 @@ msgstr "Editing an option" msgid "Modification d'une question" msgstr "Editing a question" -#: elections/templates/elections/results/rank.html:39 +#: elections/templates/elections/results/rank.html:38 #, python-format msgid "" -"L'option %(winner)s est préférée à l'option %(loser)s par %(cell)s voix." +"L'option %(winner)s est préférée à l'option %(loser)s par %(value)s voix." msgstr "" -"The %(winner)s option is preferred to the %(loser)s option by %(cell)s votes." +"The %(winner)s option is preferred to the %(loser)s option by %(value)s " +"votes." -#: elections/templates/elections/results/rank.html:51 +#: elections/templates/elections/results/rank.html:49 msgid "" "La matrice des résultats montre les points d'avance, l'option gagnante est " "affichée sur la colonne et la perdante sur la ligne. " @@ -547,30 +548,30 @@ msgstr "Confirm" msgid "Annuler" msgstr "Cancel" -#: elections/templates/elections/vote/rank.html:154 +#: elections/templates/elections/vote/rank.html:151 msgid "Classement" msgstr "Ranking" -#: elections/templates/elections/vote/rank.html:155 +#: elections/templates/elections/vote/rank.html:152 #: elections/templates/elections/vote/select.html:24 msgid "Option(s) selectionnée(s)" msgstr "Selected option(s)" -#: elections/templates/elections/vote/rank.html:175 -#: elections/templates/elections/vote/rank.html:228 +#: elections/templates/elections/vote/rank.html:172 +#: elections/templates/elections/vote/rank.html:225 msgid "Utiliser le formulaire classique" msgstr "Use the traditional form" -#: elections/templates/elections/vote/rank.html:180 +#: elections/templates/elections/vote/rank.html:177 msgid "Utiliser le cliquer-déposer" msgstr "Use Drag & Drop" -#: elections/templates/elections/vote/rank.html:238 +#: elections/templates/elections/vote/rank.html:235 #, python-format msgid "Rang %(i)s" msgstr "Rank %(i)s" -#: elections/templates/elections/vote/rank.html:249 +#: elections/templates/elections/vote/rank.html:246 msgid "Ajouter un rang" msgstr "Add an rank" @@ -590,7 +591,7 @@ msgstr "The maximum ranking is {}." msgid "Le classement minimal est 1." msgstr "The minimum ranking is 1." -#: elections/utils.py:335 +#: elections/utils.py:339 msgid "" "Format invalide. Vérifiez que le fichier est bien formé (i.e. chaque ligne " "de la forme 'login,nom,email')." @@ -598,23 +599,23 @@ msgstr "" "Invalid format. Check that the file is properly formed (i.e. each line of " "the form 'login,name,e-mail')." -#: elections/utils.py:349 +#: elections/utils.py:353 msgid "La ligne {} n'a pas le bon nombre d'éléments." msgstr "The line {} has the wrong number of elements." -#: elections/utils.py:354 +#: elections/utils.py:358 msgid "Valeur manquante dans la ligne {} : 'login'." msgstr "Missing value in line {}: 'login'." -#: elections/utils.py:359 +#: elections/utils.py:363 msgid "Doublon dans les logins : lignes {} et {}." msgstr "Duplicate logins: lines {} and {}." -#: elections/utils.py:367 +#: elections/utils.py:371 msgid "Valeur manquante dans la ligne {} : 'nom'." msgstr "Missing value in line {}: 'name'." -#: elections/utils.py:373 +#: elections/utils.py:377 msgid "Adresse mail invalide à la ligne {} : '{}'." msgstr "Invalid e-mail address in line {}: '{}'."