v1.1: Add weekly introductions

- Create a new migration adding a Weeks table, allowing for new weekly introductions
     and paving the way for multiple week handling.
 - Add route to update the weekly introduction
 - Move the week rendering to a specific week file
 - Update the templates to use the week number from the week data
 - Update templates to render and edit weekly introductions
This commit is contained in:
trotFunky 2024-07-23 21:51:51 +01:00
parent 9911895b5b
commit 67ce54e992
12 changed files with 165 additions and 71 deletions

View file

@ -2,7 +2,7 @@
<h3>Vérité {{ truth.number }}</h3>
<p>{{ truth.rendered_text | safe }}</p>
<hr/>
<form action="/{{ week_number }}/edit/{{ truth.number }}" method="POST">
<form action="/{{ week_data.number }}/edit/{{ truth.number }}" method="POST">
{% include "truth_editor" %}
</form>
</div>

View file

@ -33,11 +33,25 @@
{% endif %}
</div>
<h2>Semaine {{ week_number }}</h2>
<h2>Semaine {{ week_data.number }}</h2>
<div class="page_body">
<div class="truth_list">
<div class="week_intro">
{{ week_data.rendered_text | safe }}
{%- if user.is_admin == true -%}
<hr/>
<form action="/{{ week_data.number }}/edit" method="post">
<textarea class="editor" name="raw_intro">
{{- week_data.raw_text -}}
</textarea>
<button>
Modifier l'introduction
</button>
</form>
{% endif %}
</div>
{% if user.logged_in == true and user.is_admin == false %}
<form id="truths" action="/{{ week_number }}/vote" method="POST">
<form id="truths" action="/{{ week_data.number }}/vote" method="POST">
{% endif %}
{# Truths start at 1 but the array starts at 0 #}
@ -77,7 +91,7 @@
{% if user.is_admin == true %}
<div class="individual_truth">
<h3>Nouvelle vérité</h3>
<form action="/{{ week_number }}/new" method="POST">
<form action="/{{ week_data.number }}/new" method="POST">
{% include "truth_editor" %}
</form>
</div>

View file

@ -1,4 +1,4 @@
<textarea class="truth_editor" name="truth_raw_text">
<textarea class="editor" name="truth_raw_text">
{%- if truth.raw_text -%}
{{- truth.raw_text -}}
{%- endif -%}