From a797180b0dc9a401448b9edc715bfedcc46d7d4e Mon Sep 17 00:00:00 2001 From: philipp Date: Wed, 22 May 2024 08:04:17 +0200 Subject: [PATCH] allow to add reason for canceled event; fixes #530 --- src/model/planned_event.rs | 10 +++++----- src/model/trip.rs | 9 +++++---- templates/planned.html.tera | 6 +++--- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/model/planned_event.rs b/src/model/planned_event.rs index ec8c04d..422f14f 100644 --- a/src/model/planned_event.rs +++ b/src/model/planned_event.rs @@ -246,16 +246,16 @@ INNER JOIN trip_details ON planned_event.trip_details_id = trip_details.id", let coxes = Registration::all_cox(db, self.id).await; for user in coxes { if let Some(user) = User::find_by_name(db, &user.name).await { - let notes = match update.notes { - Some(n) if !n.is_empty() => n, - _ => ".", + let notes = if let Some(notes) = update.notes { + format!("Grund der Absage: {notes}") + } else { + String::from("") }; - Notification::create( db, &user, &format!( - "Die Ausfahrt {} am {} um {} wurde abgesagt{}", + "Die Ausfahrt {} am {} um {} wurde abgesagt. {}", self.name, self.day, self.planned_starting_time, notes ), "Absage Ausfahrt", diff --git a/src/model/trip.rs b/src/model/trip.rs index 2c04b0c..9493d3f 100644 --- a/src/model/trip.rs +++ b/src/model/trip.rs @@ -223,16 +223,17 @@ WHERE day=? .rower; for user in rowers { if let Some(user) = User::find_by_name(db, &user.name).await { - let notes = match update.notes { - Some(n) if !n.is_empty() => n, - _ => ".", + let notes = if let Some(notes) = update.notes { + format!("Grund der Absage: {notes}") + } else { + String::from("") }; Notification::create( db, &user, &format!( - "Die Ausfahrt von {} am {} um {} wurde abgesagt{}", + "Die Ausfahrt von {} am {} um {} wurde abgesagt. {}", update.cox.user.name, update.trip.day, update.trip.planned_starting_time, diff --git a/templates/planned.html.tera b/templates/planned.html.tera index e8ae532..d757865 100644 --- a/templates/planned.html.tera +++ b/templates/planned.html.tera @@ -216,7 +216,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 Ruderer', name='max_people', type='number', required=true, value=planned_event.max_people, min='1') }} {{ 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) }} {{ macros::checkbox(label='Gesperrt', name='is_locked', id=planned_event.id,checked=planned_event.is_locked) }} @@ -243,11 +243,11 @@
+ {{ macros::input(label='Grund der Absage', name='notes', type='input', value='') }} {{ macros::input(label='', name='max_people', type='hidden', value=0) }} {{ macros::input(label='', name='name', type='hidden', value=planned_event.name) }} {{ macros::input(label='', name='max_people', type='hidden', value=planned_event.max_people) }} {{ macros::input(label='', name='planned_amount_cox', type='hidden', value=planned_event.planned_amount_cox) }} - {{ macros::input(label='', name='notes', type='hidden', value=planned_event.notes) }} {{ macros::input(label='', name='always_show', type='hidden', value=planned_event.always_show) }} {{ macros::input(label='', name='is_locked', type='hidden', value=planned_event.is_locked) }} @@ -367,7 +367,7 @@

Ausfahrt absagen

{{ macros::input(label='', name='max_people', type='hidden', value=0) }} - {{ macros::input(label='', name='notes', type='hidden', value=trip.notes) }} + {{ macros::input(label='Grund der Absage', name='notes', type='input', value='') }} {{ macros::input(label='', name='always_show', type='hidden', value=trip.always_show) }} {{ macros::input(label='', name='is_locked', type='hidden', value=trip.is_locked) }} {{ macros::input(label='', name='trip_type', type='hidden', value=trip.trip_type_id) }}