From 072889173f43ae0d373ed5b889cf3a3a7b220138 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Mon, 29 Jul 2024 22:53:36 +0100 Subject: [PATCH] week: Add week number to the DisplayTruth In order to have all the relevant information for displaying a truth everywhere, add its week number. Fetch it during the week rendering and use it for the link back. --- src/database_records.rs | 1 + src/week.rs | 2 +- templates/weeks/truth.html.tera | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/database_records.rs b/src/database_records.rs index b647a2c..001df45 100644 --- a/src/database_records.rs +++ b/src/database_records.rs @@ -31,6 +31,7 @@ pub struct Truth { #[serde(crate = "rocket::serde")] pub struct DisplayTruth { id: u32, + week: u8, number: u8, author_id: u16, rendered_text: String, diff --git a/src/week.rs b/src/week.rs index 06bbbb6..0c56cd7 100644 --- a/src/week.rs +++ b/src/week.rs @@ -64,7 +64,7 @@ pub async fn week(week_number: u8, mut db: Connection, cookies: &CookieJar<' vote_data: vote_data }) } else { - let truths: Vec = match sqlx::query_as("SELECT id, number, author_id, rendered_text FROM Truths WHERE week == $1 ORDER BY number") + let truths: Vec = match sqlx::query_as("SELECT id, week, number, author_id, rendered_text FROM Truths WHERE week == $1 ORDER BY number") .bind(week_number) .fetch_all(&mut **db).await { Ok(v) => v, diff --git a/templates/weeks/truth.html.tera b/templates/weeks/truth.html.tera index 266a82b..ca52998 100644 --- a/templates/weeks/truth.html.tera +++ b/templates/weeks/truth.html.tera @@ -5,7 +5,7 @@ {%- endif -%}
-

Vérité {{ truth.number }}

+

Vérité {{ truth.number }}

{{ truth.rendered_text | safe }}

{% if user.logged_in %}