move always_show to tripdetails

This commit is contained in:
2023-07-23 19:45:48 +02:00
parent 61961b24e2
commit c32c8bb643
12 changed files with 84 additions and 52 deletions

View File

@ -36,6 +36,7 @@ async fn create(
data.notes,
data.allow_guests,
data.trip_type,
data.always_show,
)
.await;
@ -43,14 +44,7 @@ async fn create(
//just created
//the object
PlannedEvent::create(
db,
data.name,
data.planned_amount_cox,
data.always_show,
trip_details,
)
.await;
PlannedEvent::create(db, data.name, data.planned_amount_cox, trip_details).await;
Flash::success(Redirect::to("/"), "Successfully planned the event")
}

View File

@ -24,6 +24,7 @@ struct AddTripForm<'r> {
notes: Option<&'r str>,
trip_type: Option<i64>,
allow_guests: bool,
always_show: bool,
}
#[post("/trip", data = "<data>")]
@ -40,6 +41,7 @@ async fn create(
data.notes,
data.allow_guests,
data.trip_type,
data.always_show,
)
.await;
let trip_details = TripDetails::find_by_id(db, trip_details_id).await.unwrap(); //Okay, bc just
@ -63,6 +65,7 @@ struct EditTripForm<'r> {
max_people: i32,
notes: Option<&'r str>,
trip_type: Option<i64>,
always_show: bool,
}
#[post("/trip/<trip_id>", data = "<data>")]
@ -73,7 +76,17 @@ async fn update(
cox: CoxUser,
) -> Flash<Redirect> {
if let Some(trip) = Trip::find_by_id(db, trip_id).await {
match Trip::update_own(db, &cox, &trip, data.max_people, data.notes, data.trip_type).await {
match Trip::update_own(
db,
&cox,
&trip,
data.max_people,
data.notes,
data.trip_type,
data.always_show,
)
.await
{
Ok(_) => Flash::success(Redirect::to("/"), "Ausfahrt erfolgreich aktualisiert."),
Err(TripUpdateError::NotYourTrip) => {
Flash::error(Redirect::to("/"), "Nicht deine Ausfahrt!")