From 47920305c440c2881983c6ef9e011aacf374a7b1 Mon Sep 17 00:00:00 2001 From: philipp Date: Thu, 8 Jun 2023 11:28:25 +0200 Subject: [PATCH] allow updating pinning an planned_trip --- src/model/planned_event.rs | 4 +++- src/rest/admin/planned_event.rs | 9 ++++++++- templates/index.html.tera | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/model/planned_event.rs b/src/model/planned_event.rs index 0bfd7ea..0180bc2 100644 --- a/src/model/planned_event.rs +++ b/src/model/planned_event.rs @@ -211,10 +211,12 @@ FROM user_trip WHERE trip_details_id = (SELECT trip_details_id FROM planned_even planned_amount_cox: i32, max_people: i32, notes: Option<&str>, + always_show: bool, ) { sqlx::query!( - "UPDATE planned_event SET planned_amount_cox = ? WHERE id = ?", + "UPDATE planned_event SET planned_amount_cox = ?, always_show=? WHERE id = ?", planned_amount_cox, + always_show, self.id ) .execute(db) diff --git a/src/rest/admin/planned_event.rs b/src/rest/admin/planned_event.rs index 40837fb..c1bba28 100644 --- a/src/rest/admin/planned_event.rs +++ b/src/rest/admin/planned_event.rs @@ -62,6 +62,7 @@ struct UpdatePlannedEventForm<'r> { planned_amount_cox: i32, max_people: i32, notes: Option<&'r str>, + always_show: bool, } #[put("/planned-event", data = "")] @@ -73,7 +74,13 @@ async fn update( match PlannedEvent::find_by_id(db, data.id).await { Some(planned_event) => { planned_event - .update(db, data.planned_amount_cox, data.max_people, data.notes) + .update( + db, + data.planned_amount_cox, + data.max_people, + data.notes, + data.always_show, + ) .await; Flash::success(Redirect::to("/"), "Successfully edited the event") } diff --git a/templates/index.html.tera b/templates/index.html.tera index 55473ba..f6f4250 100644 --- a/templates/index.html.tera +++ b/templates/index.html.tera @@ -130,6 +130,7 @@ {{ 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') }} {{ macros::input(label='Anmerkungen', name='notes', type='input', value=planned_event.notes) }}