allow to add reason for canceled event; fixes #530 #532

Merged
philipp merged 1 commits from reason-for-canceled-event into main 2024-05-22 08:14:01 +02:00
3 changed files with 13 additions and 12 deletions
Showing only changes of commit a797180b0d - Show all commits

View File

@ -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; let coxes = Registration::all_cox(db, self.id).await;
for user in coxes { for user in coxes {
if let Some(user) = User::find_by_name(db, &user.name).await { if let Some(user) = User::find_by_name(db, &user.name).await {
let notes = match update.notes { let notes = if let Some(notes) = update.notes {
Some(n) if !n.is_empty() => n, format!("Grund der Absage: {notes}")
_ => ".", } else {
String::from("")
}; };
Notification::create( Notification::create(
db, db,
&user, &user,
&format!( &format!(
"Die Ausfahrt {} am {} um {} wurde abgesagt{}", "Die Ausfahrt {} am {} um {} wurde abgesagt. {}",
self.name, self.day, self.planned_starting_time, notes self.name, self.day, self.planned_starting_time, notes
), ),
"Absage Ausfahrt", "Absage Ausfahrt",

View File

@ -223,16 +223,17 @@ WHERE day=?
.rower; .rower;
for user in rowers { for user in rowers {
if let Some(user) = User::find_by_name(db, &user.name).await { if let Some(user) = User::find_by_name(db, &user.name).await {
let notes = match update.notes { let notes = if let Some(notes) = update.notes {
Some(n) if !n.is_empty() => n, format!("Grund der Absage: {notes}")
_ => ".", } else {
String::from("")
}; };
Notification::create( Notification::create(
db, db,
&user, &user,
&format!( &format!(
"Die Ausfahrt von {} am {} um {} wurde abgesagt{}", "Die Ausfahrt von {} am {} um {} wurde abgesagt. {}",
update.cox.user.name, update.cox.user.name,
update.trip.day, update.trip.day,
update.trip.planned_starting_time, update.trip.planned_starting_time,

View File

@ -216,7 +216,7 @@
<input type="hidden" name="_method" value="put" /> <input type="hidden" name="_method" value="put" />
<input type="hidden" name="id" value="{{ planned_event.id }}" /> <input type="hidden" name="id" value="{{ planned_event.id }}" />
{{ macros::input(label='Titel', name='name', type='input', value=planned_event.name) }} {{ 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::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='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) }} {{ macros::checkbox(label='Gesperrt', name='is_locked', id=planned_event.id,checked=planned_event.is_locked) }}
@ -243,11 +243,11 @@
<form action="/admin/planned-event" method="post" class="grid"> <form action="/admin/planned-event" method="post" class="grid">
<input type="hidden" name="_method" value="put" /> <input type="hidden" name="_method" value="put" />
<input type="hidden" name="id" value="{{ planned_event.id }}" /> <input type="hidden" name="id" value="{{ planned_event.id }}" />
{{ 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='max_people', type='hidden', value=0) }}
{{ macros::input(label='', name='name', type='hidden', value=planned_event.name) }} {{ 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='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='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='always_show', type='hidden', value=planned_event.always_show) }}
{{ macros::input(label='', name='is_locked', type='hidden', value=planned_event.is_locked) }} {{ macros::input(label='', name='is_locked', type='hidden', value=planned_event.is_locked) }}
<input value="Ausfahrt absagen" class="btn btn-alert" type="submit" /> <input value="Ausfahrt absagen" class="btn btn-alert" type="submit" />
@ -367,7 +367,7 @@
<h3 class="text-primary-950 dark:text-white font-bold uppercase tracking-wide mb-2">Ausfahrt absagen</h3> <h3 class="text-primary-950 dark:text-white font-bold uppercase tracking-wide mb-2">Ausfahrt absagen</h3>
<form action="/cox/trip/{{ trip.id }}" method="post" class="grid"> <form action="/cox/trip/{{ trip.id }}" method="post" class="grid">
{{ macros::input(label='', name='max_people', type='hidden', value=0) }} {{ 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='always_show', type='hidden', value=trip.always_show) }}
{{ macros::input(label='', name='is_locked', type='hidden', value=trip.is_locked) }} {{ 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) }} {{ macros::input(label='', name='trip_type', type='hidden', value=trip.trip_type_id) }}