frontend for new db

This commit is contained in:
2023-10-30 13:39:58 +01:00
parent e256d7274d
commit 2d520298e7
4 changed files with 173 additions and 118 deletions

View File

@ -239,9 +239,17 @@ ORDER BY departure DESC
log: LogToAdd,
created_by_user: &User,
) -> Result<(), LogbookCreateError> {
println!("{log:#?}");
let Some(boat) = Boat::find_by_id(db, log.boat_id).await else {
return Err(LogbookCreateError::BoatNotFound);
};
if let Ok(log_to_finalize) = TryInto::<LogToFinalize>::try_into(log.clone()) {
//TODO: fix clone()
if !boat.shipmaster_allowed(created_by_user).await {
return Err(LogbookCreateError::UserNotAllowedToUseBoat);
}
let mut tx = db.begin().await.unwrap();
let inserted_row = sqlx::query!(
@ -277,10 +285,6 @@ ORDER BY departure DESC
return Err(LogbookCreateError::ArrivalSetButNotRemainingTwo);
}
let Some(boat) = Boat::find_by_id(db, log.boat_id).await else {
return Err(LogbookCreateError::BoatNotFound);
};
if boat.is_locked(db).await {
return Err(LogbookCreateError::BoatLocked);
}