From 30a6bc710962c101a419aa296d1948cb4a8bb22a Mon Sep 17 00:00:00 2001 From: philipp Date: Tue, 4 Jun 2024 08:12:20 +0200 Subject: [PATCH 1/2] allow event trip_type update --- src/model/event.rs | 4 +++- src/tera/admin/event.rs | 2 ++ templates/planned.html.tera | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/model/event.rs b/src/model/event.rs index 3715ab1..f03ada6 100644 --- a/src/model/event.rs +++ b/src/model/event.rs @@ -105,6 +105,7 @@ pub struct EventUpdate<'a> { pub notes: Option<&'a str>, pub always_show: bool, pub is_locked: bool, + pub trip_type_id: Option, } impl Event { @@ -244,11 +245,12 @@ WHERE trip_details.id=? let was_already_cancelled = tripdetails.max_people == 0; sqlx::query!( - "UPDATE trip_details SET max_people = ?, notes = ?, always_show = ?, is_locked = ? WHERE id = ?", + "UPDATE trip_details SET max_people = ?, notes = ?, always_show = ?, is_locked = ?, trip_type_id = ? WHERE id = ?", update.max_people, update.notes, update.always_show, update.is_locked, + update.trip_type_id, self.trip_details_id ) .execute(db) diff --git a/src/tera/admin/event.rs b/src/tera/admin/event.rs index 7fa5303..cefde95 100644 --- a/src/tera/admin/event.rs +++ b/src/tera/admin/event.rs @@ -49,6 +49,7 @@ struct UpdateEventForm<'r> { notes: Option<&'r str>, always_show: bool, is_locked: bool, + trip_type: Option, } #[put("/planned-event", data = "")] @@ -64,6 +65,7 @@ async fn update( notes: data.notes, always_show: data.always_show, is_locked: data.is_locked, + trip_type_id: data.trip_type, }; match Event::find_by_id(db, data.id).await { Some(planned_event) => { diff --git a/templates/planned.html.tera b/templates/planned.html.tera index 8e94636..0ff4851 100644 --- a/templates/planned.html.tera +++ b/templates/planned.html.tera @@ -220,6 +220,7 @@ {{ macros::input(label='Anzahl Steuerleute', name='planned_amount_cox', type='number', value=event.planned_amount_cox, required=true, min='0') }} {{ macros::checkbox(label='Immer anzeigen', name='always_show', id=event.id,checked=event.always_show) }} {{ macros::checkbox(label='Gesperrt', name='is_locked', id=event.id,checked=event.is_locked) }} + {{ macros::select(label='Typ', name='trip_type', data=trip_types, default='Reguläre Ausfahrt', selected_id=event.trip_type_id) }} {{ macros::input(label='Anmerkungen', name='notes', type='input', value=event.notes) }} From ab88ce32307ecba033792ef42b556a51195c8007 Mon Sep 17 00:00:00 2001 From: philipp Date: Tue, 4 Jun 2024 08:13:24 +0200 Subject: [PATCH 2/2] fix tests --- src/model/notification.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/model/notification.rs b/src/model/notification.rs index 554f40e..8919cb9 100644 --- a/src/model/notification.rs +++ b/src/model/notification.rs @@ -238,6 +238,7 @@ mod test { notes: event.notes.as_deref(), always_show: event.always_show, is_locked: event.is_locked, + trip_type_id: None, }; event.update(&pool, &cancel_update).await; @@ -267,6 +268,7 @@ mod test { notes: event.notes.as_deref(), always_show: event.always_show, is_locked: event.is_locked, + trip_type_id: None, }; event.update(&pool, &update).await; assert!(Notification::for_user(&pool, &rower).await.is_empty());