From 3462ac5963f085d419d2090fdec4dac1d6bb04b1 Mon Sep 17 00:00:00 2001 From: philipp Date: Wed, 24 Jan 2024 22:47:53 +0100 Subject: [PATCH] allow changing title of planned-event; fixes #52 --- src/model/planned_event.rs | 4 +++- src/tera/admin/planned_event.rs | 2 ++ templates/planned.html.tera | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/model/planned_event.rs b/src/model/planned_event.rs index a4e61e8..885ec64 100644 --- a/src/model/planned_event.rs +++ b/src/model/planned_event.rs @@ -210,6 +210,7 @@ INNER JOIN trip_details ON planned_event.trip_details_id = trip_details.id", pub async fn update( &self, db: &SqlitePool, + name: &str, planned_amount_cox: i32, max_people: i32, notes: Option<&str>, @@ -217,7 +218,8 @@ INNER JOIN trip_details ON planned_event.trip_details_id = trip_details.id", is_locked: bool, ) { sqlx::query!( - "UPDATE planned_event SET planned_amount_cox = ? WHERE id = ?", + "UPDATE planned_event SET name = ?, planned_amount_cox = ? WHERE id = ?", + name, planned_amount_cox, self.id ) diff --git a/src/tera/admin/planned_event.rs b/src/tera/admin/planned_event.rs index 293e022..da33c3d 100644 --- a/src/tera/admin/planned_event.rs +++ b/src/tera/admin/planned_event.rs @@ -43,6 +43,7 @@ async fn create( #[derive(FromForm)] struct UpdatePlannedEventForm<'r> { id: i64, + name: &'r str, planned_amount_cox: i32, max_people: i32, notes: Option<&'r str>, @@ -61,6 +62,7 @@ async fn update( planned_event .update( db, + data.name, data.planned_amount_cox, data.max_people, data.notes, diff --git a/templates/planned.html.tera b/templates/planned.html.tera index 2a0aefd..d9974ad 100644 --- a/templates/planned.html.tera +++ b/templates/planned.html.tera @@ -181,6 +181,7 @@
+ {{ macros::input(label='Titel', name='name', type='input', value=planned_event.name) }} {{ macros::input(label='Anzahl Ruderer', name='max_people', type='number', required=true, value=planned_event.max_people, min='0') }} {{ macros::input(label='Anzahl Steuerleute', name='planned_amount_cox', type='number', value=planned_event.planned_amount_cox, required=true, min='0') }} {{ macros::checkbox(label='Immer anzeigen', name='always_show', id=planned_event.id,checked=planned_event.always_show) }}