allow trip_type edit of trip
This commit is contained in:
@ -11,6 +11,7 @@ use crate::model::{
|
||||
planned_event::PlannedEvent,
|
||||
trip::{CoxHelpError, Trip, TripDeleteError, TripUpdateError},
|
||||
tripdetails::TripDetails,
|
||||
triptype::TripType,
|
||||
user::CoxUser,
|
||||
};
|
||||
|
||||
@ -63,6 +64,7 @@ async fn create(db: &State<SqlitePool>, data: Form<AddTripForm>, cox: CoxUser) -
|
||||
struct EditTripForm {
|
||||
max_people: i32,
|
||||
notes: Option<String>,
|
||||
trip_type: Option<i64>,
|
||||
}
|
||||
|
||||
#[post("/trip/<trip_id>", data = "<data>")]
|
||||
@ -73,7 +75,16 @@ 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.clone()).await {
|
||||
match Trip::update_own(
|
||||
db,
|
||||
&cox,
|
||||
&trip,
|
||||
data.max_people,
|
||||
data.notes.clone(),
|
||||
data.trip_type,
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(_) => Flash::success(Redirect::to("/"), "Ausfahrt erfolgreich aktualisiert."),
|
||||
Err(TripUpdateError::NotYourTrip) => {
|
||||
Flash::error(Redirect::to("/"), "Nicht deine Ausfahrt!")
|
||||
|
Reference in New Issue
Block a user