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.
This commit is contained in:
parent
4e1e9facc6
commit
072889173f
3 changed files with 3 additions and 2 deletions
|
@ -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,
|
||||
|
|
|
@ -64,7 +64,7 @@ pub async fn week(week_number: u8, mut db: Connection<Db>, cookies: &CookieJar<'
|
|||
vote_data: vote_data
|
||||
})
|
||||
} else {
|
||||
let truths: Vec<DisplayTruth> = match sqlx::query_as("SELECT id, number, author_id, rendered_text FROM Truths WHERE week == $1 ORDER BY number")
|
||||
let truths: Vec<DisplayTruth> = 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,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
{%- endif -%}
|
||||
|
||||
<div class="individual_truth">
|
||||
<a href="#{{ truth.number }}"><h3 id="{{ truth.number }}">Vérité {{ truth.number }}</h3></a>
|
||||
<a href="/{{ truth.week }}/#{{ truth.number }}"><h3 id="{{ truth.number }}">Vérité {{ truth.number }}</h3></a>
|
||||
<p>{{ truth.rendered_text | safe }}</p>
|
||||
{% if user.logged_in %}
|
||||
<hr/>
|
||||
|
|
Loading…
Add table
Reference in a new issue