Rajoute des couleurs sur le tableau récapitulatif
This commit is contained in:
parent
dd32be28c0
commit
2397fdb715
2 changed files with 14 additions and 4 deletions
|
@ -35,8 +35,8 @@
|
||||||
</span>
|
</span>
|
||||||
</th>
|
</th>
|
||||||
|
|
||||||
{% for cell in line %}
|
{% for cell, class in line %}
|
||||||
<td class="has-text-centered has-tooltip-primary" {% 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 %}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>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tr>
|
</tr>
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
|
|
|
@ -249,11 +249,21 @@ 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.zeros((n, n), dtype=int)
|
||||||
|
matrix = np.zeros((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] = d.amount
|
||||||
|
|
||||||
|
for i in range(n):
|
||||||
|
for j in range(n):
|
||||||
|
if _matrix[i, j] > _matrix[j, i]:
|
||||||
|
matrix[i, j] = (_matrix[i, j], "is-success")
|
||||||
|
elif _matrix[i, j] < _matrix[j, i]:
|
||||||
|
matrix[i, j] = (_matrix[i, j], "is-danger")
|
||||||
|
else:
|
||||||
|
matrix[i, j] = (_matrix[i, j], "")
|
||||||
|
|
||||||
return render_to_string(
|
return render_to_string(
|
||||||
"elections/results/rank.html",
|
"elections/results/rank.html",
|
||||||
|
|
Loading…
Add table
Reference in a new issue