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 zcmX?GeZG1F3sb!>0|UcGaRvr61_p-z;tUM>3=9lr5)2GY3=9lu5)2G}3=9k}B^VgY z85kHWBpDcF85kG}BpDcF7#JA(BpDb|85kH=OENHoGBPj-N-;3(V_;xNmu6rnWnf@X zlVM=cV_;yIBg4SJ%fP^JT84o^n1O-erVImv7y|>tTN#FW25klg1{PTc1`!4Z1_N0J z237_J23J`I22}S{9BQML5_ieL0SnC5>`r(DDzQ* zgjkjm#J+YYzkZSu#Deuo3=BF93=9{P7#Oq|7#RL4K`hizW?&FtU|=v+W?&Ep1)VY^ zgyNJL7}OXT7*doO7*rS-7`l}qQMN%DqW_vQ1A{RG0|TQ9B<@XBAm%x%K=cQwfE`}X z5T?SwAjH7Hke~tyx?&ZGMb#>hG%;C)fq|QWfnf#IfGsMJv~W;`fkBCZf#Eh({2!F& zR)s{VgeoLW$f!c%UR4zmGB&CV4EziX4AEfudIpAURfrEuR2jgDu~ik~ppB{!mmY!A zr=aRCs6vAFA=Kc{s*t$lQiC{1P7M;Gj%pB#lhhy~Q>g|CsrhOU^N*-8FbLN(Ffd$) zYJ3fq;8Tahy`nnAU}trRh2czV5JEOnbn#M3=eykTl@04TCuIJZ(tOZ`FpRog3Pa z5c!}D38`<|3=9WBiBSjQ!NWR`kUFJP4`G~#3S7~F_~fPz#3A2wATDRsh0y#^T2dEc zv9d12VOF}3k~0L#Z_$Nh=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WVqY7SUq4X^V!=8k1_m7l28Q!W3=CQf3=DsiAQq}CGcX7+Fff=XGcbsQf=(F{ zLb1vW3~CGv49Ut23@Qu^3|-2QC|j=#(SKE$fx(!80W1lMdlMCic}^-2{r)Oohu1TN zsxUAJF)%R1t3ZOTNCje1l?o(HOj2QB;AUW8SPnH{vkD|F98h6kP-0+UxCIse3#GYK zAyF!>3P}^vs*t!>QH6wzwJHMxKLZ0p6j;8Vfgwv3;=^K925@3*QH3~YgDS+OhoSUI zsJip2kf414HTaV%ByKs?AP$mMgM_Gq8pPs6HAu)*sDT56VV)Yq{KIMt48rvc3=G$x z8ec&rc-0|sub>Vw*hw8?VHlL3p$>_|8g&K+7e)q#c6EqD&uB0(urM$%T+)DqKG3FUX2Lek7UQ%Hzz zGKGZrL5R9~hGS3#H%uWx@&?NP3RTEy21!(WW(*8W3=9nNW{||E1f{jiASIlU8N|T> zW)O!Ym_ZU}u^A){m76gz#4<22^q4U)%wk|*cm>v9&%n@X4k61S-pBy9v)F)-AF3Wi)O1_pHo28L-?khtFmrB7Qy48CCn ziJJRXkhpwd1&M+`P(F(_B;+KlAwJf!hRB;)Lux-eYlwv*Q1N_ghR-8 S8JldrslJs1B0kx`h8F;nu?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 {}: '{}'."