allow updating pinning an planned_trip

This commit is contained in:
philipp 2023-06-08 11:28:25 +02:00
parent 5d0bfddadf
commit 47920305c4
3 changed files with 12 additions and 2 deletions

View File

@ -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)

View File

@ -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 = "<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")
}

View File

@ -130,6 +130,7 @@
<input type="hidden" name="id" value="{{ planned_event.id }}" />
{{ 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) }}
<input value="Bearbeiten" class="btn btn-primary" type="submit" />