diff --git a/src/tera/log.rs b/src/tera/log.rs index c2626a5..013b67f 100644 --- a/src/tera/log.rs +++ b/src/tera/log.rs @@ -210,10 +210,19 @@ async fn create_kiosk( data: Form, _kiosk: KioskCookie, ) -> Flash { - let creator = if let Some(shipmaster) = data.shipmaster { - User::find_by_id(db, shipmaster as i32).await.unwrap() + let Some(boat) = Boat::find_by_id(db, data.boat_id).await else { + return Flash::error(Redirect::to("/log"), "Boot gibt's nicht"); + }; + let creator = if boat.amount_seats == 1 && boat.owner.is_some() { + User::find_by_id(db, boat.owner.unwrap() as i32) + .await + .unwrap() } else { - User::find_by_id(db, data.rowers[0] as i32).await.unwrap() + if let Some(shipmaster) = data.shipmaster { + User::find_by_id(db, shipmaster as i32).await.unwrap() + } else { + User::find_by_id(db, data.rowers[0] as i32).await.unwrap() + } }; Log::create( db,