trotFunky
207ce6c1d2
I made a choice to only log confirmed votes : there is no blank vote in the database. This means that when fetching a user's vote, if they have not voted for everyone there will be votes missing. As this is sent to the templating engine via a Vector, the ordering of the votes will be incorrect : all existing votes will follow each other, and there will be missing votes at the end. Update the select logic in the truth template to account for that by checking the truth_id directly, rather than via the index of the array. (O(N²)...) Remove 'has_vote' as this is not useful anymore.
28 lines
1 KiB
Text
28 lines
1 KiB
Text
<div class="individual_truth">
|
|
<h3>Vérité {{ truth.number }}</h3>
|
|
<p>{{ truth.rendered_text | safe }}</p>
|
|
{% if user.logged_in %}
|
|
<hr/>
|
|
<label>
|
|
{%- if truth.author_id == user.id -%}
|
|
Tu l'as fait :)
|
|
{%- else -%}
|
|
Qui l'a fait ?
|
|
<select form="truths" name="truth_votes[{{ truth.id }}]">
|
|
<option value="0">---</option>
|
|
{% for player in other_players %}
|
|
{# Check if we should pre-select an existing vote #}
|
|
{% set_global is_selected = "" %}
|
|
{% for vote in user.votes %}
|
|
{% if truth.id == vote.truth_id and player.id == vote.voted_id %}
|
|
{% set_global is_selected = "selected" %}
|
|
{% break %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
<option value="{{ player.id }}" {{- is_selected -}}>{{ player.name }}</option>
|
|
{% endfor %}
|
|
</select>
|
|
{%- endif -%}
|
|
</label>
|
|
{% endif %}
|
|
</div>
|