Merge pull request 'don't respond with 500 if no rower is selected' (#451) from require-user-for-logentry into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 7m46s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 6m18s

Reviewed-on: #451
This commit is contained in:
philipp 2024-04-28 19:25:33 +02:00
commit d01895df90

View File

@ -250,7 +250,13 @@ async fn create_kiosk(
} else if let Some(shipmaster) = data.shipmaster { } else if let Some(shipmaster) = data.shipmaster {
User::find_by_id(db, shipmaster as i32).await.unwrap() User::find_by_id(db, shipmaster as i32).await.unwrap()
} else { } else {
User::find_by_id(db, data.rowers[0] as i32).await.unwrap() let Some(rower) = data.rowers.get(0) else {
return Flash::error(
Redirect::to("/log"),
"Ausfahrt ohne Benutzer kann nicht angelegt werden.",
);
};
User::find_by_id(db, *rower as i32).await.unwrap()
}; };
Log::create( Log::create(
db, db,