On affiche l'abréviation dans le tableu des résultats
This commit is contained in:
parent
6ba5a5c620
commit
3601508ab2
5 changed files with 37 additions and 31 deletions
|
@ -170,6 +170,9 @@ class Option(models.Model):
|
||||||
|
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
|
def get_abbr(self, default):
|
||||||
|
return self.abbreviation or default
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if self.abbreviation:
|
if self.abbreviation:
|
||||||
return self.abbreviation + " - " + self.text
|
return self.abbreviation + " - " + self.text
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
|
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for line, o in matrix %}
|
{% for line, o in matrix %}
|
||||||
{% with loser=forloop.counter %}
|
|
||||||
<tr>
|
<tr>
|
||||||
<th class="has-text-centered">
|
<th class="has-text-centered">
|
||||||
<span class="icon-text">
|
<span class="icon-text">
|
||||||
|
@ -36,10 +35,9 @@
|
||||||
</th>
|
</th>
|
||||||
|
|
||||||
{% for cell, class in line %}
|
{% for cell, class in line %}
|
||||||
<td class="has-text-centered has-tooltip-primary {{ class }}" {% if cell %}data-tooltip="{% blocktrans with winner=forloop.counter %}L'option {{ winner }} est préférée à l'option {{ loser }} par {{ cell }} voix.{% endblocktrans %}{% endif %}">{{ cell }}</td>
|
<td class="has-text-centered has-tooltip-primary {{ class }}" {% if cell.value %}data-tooltip="{% blocktrans with winner=cell.winner loser=cell.loser value=cell.value %}L'option {{ winner }} est préférée à l'option {{ loser }} par {{ value }} voix.{% endblocktrans %}{% endif %}">{{ cell.value }}</td>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tr>
|
</tr>
|
||||||
{% endwith %}
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -238,18 +238,22 @@ class ResultsData:
|
||||||
options = list(question.options.all())
|
options = list(question.options.all())
|
||||||
n = len(options)
|
n = len(options)
|
||||||
|
|
||||||
_matrix = np.zeros((n, n), dtype=int)
|
_matrix = np.full((n, n), {"value": 0}, dtype=dict)
|
||||||
matrix = np.zeros((n, n), dtype=tuple)
|
matrix = np.empty((n, n), dtype=tuple)
|
||||||
|
|
||||||
for d in duels:
|
for d in duels:
|
||||||
i, j = options.index(d.loser), options.index(d.winner)
|
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 i in range(n):
|
||||||
for j 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")
|
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")
|
matrix[i, j] = (_matrix[i, j], "is-danger")
|
||||||
else:
|
else:
|
||||||
matrix[i, j] = (_matrix[i, j], "")
|
matrix[i, j] = (_matrix[i, j], "")
|
||||||
|
|
Binary file not shown.
|
@ -7,8 +7,8 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: 0.1\n"
|
"Project-Id-Version: 0.1\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2021-06-18 22:33+0200\n"
|
"POT-Creation-Date: 2021-06-28 21:29+0200\n"
|
||||||
"PO-Revision-Date: 2021-06-18 22:34+0200\n"
|
"PO-Revision-Date: 2021-06-28 21:30+0200\n"
|
||||||
"Last-Translator: Test Translator <test@translator>\n"
|
"Last-Translator: Test Translator <test@translator>\n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
"Language: en\n"
|
"Language: en\n"
|
||||||
|
@ -152,19 +152,19 @@ msgstr "winning option"
|
||||||
msgid "nombre de votes reçus"
|
msgid "nombre de votes reçus"
|
||||||
msgstr "number of votes received"
|
msgstr "number of votes received"
|
||||||
|
|
||||||
#: elections/models.py:192
|
#: elections/models.py:195
|
||||||
msgid "rang de l'option"
|
msgid "rang de l'option"
|
||||||
msgstr "option's ranking"
|
msgstr "option's ranking"
|
||||||
|
|
||||||
#: elections/models.py:208
|
#: elections/models.py:211
|
||||||
msgid "votes supplémentaires"
|
msgid "votes supplémentaires"
|
||||||
msgstr "extra votes"
|
msgstr "extra votes"
|
||||||
|
|
||||||
#: elections/models.py:224
|
#: elections/models.py:227
|
||||||
msgid "Nom et Prénom"
|
msgid "Nom et Prénom"
|
||||||
msgstr "Name and surname"
|
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"
|
msgid "identifiants spécifiques"
|
||||||
msgstr "dedicated credentials"
|
msgstr "dedicated credentials"
|
||||||
|
|
||||||
|
@ -470,14 +470,15 @@ msgstr "Editing an option"
|
||||||
msgid "Modification d'une question"
|
msgid "Modification d'une question"
|
||||||
msgstr "Editing a question"
|
msgstr "Editing a question"
|
||||||
|
|
||||||
#: elections/templates/elections/results/rank.html:39
|
#: elections/templates/elections/results/rank.html:38
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid ""
|
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 ""
|
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 ""
|
msgid ""
|
||||||
"La matrice des résultats montre les points d'avance, l'option gagnante est "
|
"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. "
|
"affichée sur la colonne et la perdante sur la ligne. "
|
||||||
|
@ -547,30 +548,30 @@ msgstr "Confirm"
|
||||||
msgid "Annuler"
|
msgid "Annuler"
|
||||||
msgstr "Cancel"
|
msgstr "Cancel"
|
||||||
|
|
||||||
#: elections/templates/elections/vote/rank.html:154
|
#: elections/templates/elections/vote/rank.html:151
|
||||||
msgid "Classement"
|
msgid "Classement"
|
||||||
msgstr "Ranking"
|
msgstr "Ranking"
|
||||||
|
|
||||||
#: elections/templates/elections/vote/rank.html:155
|
#: elections/templates/elections/vote/rank.html:152
|
||||||
#: elections/templates/elections/vote/select.html:24
|
#: elections/templates/elections/vote/select.html:24
|
||||||
msgid "Option(s) selectionnée(s)"
|
msgid "Option(s) selectionnée(s)"
|
||||||
msgstr "Selected option(s)"
|
msgstr "Selected option(s)"
|
||||||
|
|
||||||
#: elections/templates/elections/vote/rank.html:175
|
#: elections/templates/elections/vote/rank.html:172
|
||||||
#: elections/templates/elections/vote/rank.html:228
|
#: elections/templates/elections/vote/rank.html:225
|
||||||
msgid "Utiliser le formulaire classique"
|
msgid "Utiliser le formulaire classique"
|
||||||
msgstr "Use the traditional form"
|
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"
|
msgid "Utiliser le cliquer-déposer"
|
||||||
msgstr "Use Drag & Drop"
|
msgstr "Use Drag & Drop"
|
||||||
|
|
||||||
#: elections/templates/elections/vote/rank.html:238
|
#: elections/templates/elections/vote/rank.html:235
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Rang %(i)s"
|
msgid "Rang %(i)s"
|
||||||
msgstr "Rank %(i)s"
|
msgstr "Rank %(i)s"
|
||||||
|
|
||||||
#: elections/templates/elections/vote/rank.html:249
|
#: elections/templates/elections/vote/rank.html:246
|
||||||
msgid "Ajouter un rang"
|
msgid "Ajouter un rang"
|
||||||
msgstr "Add an rank"
|
msgstr "Add an rank"
|
||||||
|
|
||||||
|
@ -590,7 +591,7 @@ msgstr "The maximum ranking is {}."
|
||||||
msgid "Le classement minimal est 1."
|
msgid "Le classement minimal est 1."
|
||||||
msgstr "The minimum ranking is 1."
|
msgstr "The minimum ranking is 1."
|
||||||
|
|
||||||
#: elections/utils.py:335
|
#: elections/utils.py:339
|
||||||
msgid ""
|
msgid ""
|
||||||
"Format invalide. Vérifiez que le fichier est bien formé (i.e. chaque ligne "
|
"Format invalide. Vérifiez que le fichier est bien formé (i.e. chaque ligne "
|
||||||
"de la forme 'login,nom,email')."
|
"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 "
|
"Invalid format. Check that the file is properly formed (i.e. each line of "
|
||||||
"the form 'login,name,e-mail')."
|
"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."
|
msgid "La ligne {} n'a pas le bon nombre d'éléments."
|
||||||
msgstr "The line {} has the wrong number of elements."
|
msgstr "The line {} has the wrong number of elements."
|
||||||
|
|
||||||
#: elections/utils.py:354
|
#: elections/utils.py:358
|
||||||
msgid "Valeur manquante dans la ligne {} : 'login'."
|
msgid "Valeur manquante dans la ligne {} : 'login'."
|
||||||
msgstr "Missing value in line {}: 'login'."
|
msgstr "Missing value in line {}: 'login'."
|
||||||
|
|
||||||
#: elections/utils.py:359
|
#: elections/utils.py:363
|
||||||
msgid "Doublon dans les logins : lignes {} et {}."
|
msgid "Doublon dans les logins : lignes {} et {}."
|
||||||
msgstr "Duplicate logins: lines {} and {}."
|
msgstr "Duplicate logins: lines {} and {}."
|
||||||
|
|
||||||
#: elections/utils.py:367
|
#: elections/utils.py:371
|
||||||
msgid "Valeur manquante dans la ligne {} : 'nom'."
|
msgid "Valeur manquante dans la ligne {} : 'nom'."
|
||||||
msgstr "Missing value in line {}: 'name'."
|
msgstr "Missing value in line {}: 'name'."
|
||||||
|
|
||||||
#: elections/utils.py:373
|
#: elections/utils.py:377
|
||||||
msgid "Adresse mail invalide à la ligne {} : '{}'."
|
msgid "Adresse mail invalide à la ligne {} : '{}'."
|
||||||
msgstr "Invalid e-mail address in line {}: '{}'."
|
msgstr "Invalid e-mail address in line {}: '{}'."
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue