templates: Move week-related includes to a folder

In preparation to adding a new page, move the week-related included files in a specific
sub-folder.
Change includes accordingly.
This commit is contained in:
trotFunky 2024-07-27 22:41:06 +01:00
parent 36b2e61e26
commit afdac98dea
4 changed files with 4 additions and 4 deletions

View file

@ -0,0 +1,8 @@
<div class="individual_truth">
<h3>Vérité {{ truth.number }}</h3>
<p>{{ truth.rendered_text | safe }}</p>
<hr/>
<form action="/{{ week_data.number }}/edit/{{ truth.number }}" method="POST">
{% include "weeks/truth_editor" %}
</form>
</div>

View file

@ -0,0 +1,34 @@
{%- set is_disabled = "" -%}
{# If we are not during the active week, prevent changing vote but not sending a missing one. #}
{%- if week_data.is_last_week != true and user.votes | filter(attribute="truth_id", value=truth.id) -%}
{%- set is_disabled = "disabled" -%}
{%- endif -%}
<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 }}]" {{ is_disabled }}>
<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>

View file

@ -0,0 +1,26 @@
<textarea class="editor" name="truth_raw_text">
{%- if truth.raw_text -%}
{{- truth.raw_text -}}
{%- endif -%}
</textarea>
<label>Qui l'a écrit ?
<select name="truth_author">
<option value="0">---</option>
{% for player in other_players %}
{# Check if we should pre-select if the truth already exists #}
{% if truth.author_id and player.id == truth.author_id %}
{% set is_selected = "selected" %}
{% else %}
{% set is_selected = "" %}
{% endif %}
<option value="{{ player.id }}" {{- is_selected -}}>{{ player.name }}</option>
{% endfor %}
</select>
</label>
<button>
{%- if not truth.author_id -%}
Ajouter une vérité
{%- else -%}
Modifier la vérité
{%- endif -%}
</button>