diff --git a/src/model/boat.rs b/src/model/boat.rs index 6fbd59a..5a12b0e 100644 --- a/src/model/boat.rs +++ b/src/model/boat.rs @@ -148,8 +148,7 @@ ORDER BY amount_seats DESC if user.is_admin { return Self::all(db).await; } - let boats; - if user.is_cox { + let boats = if user.is_cox { boats = sqlx::query_as!( Boat, " @@ -162,9 +161,9 @@ ORDER BY amount_seats DESC ) .fetch_all(db) .await - .unwrap(); //TODO: fixme + .unwrap() //TODO: fixme } else { - boats = sqlx::query_as!( + sqlx::query_as!( Boat, " SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, skull, external @@ -176,8 +175,8 @@ ORDER BY amount_seats DESC ) .fetch_all(db) .await - .unwrap(); //TODO: fixme - } + .unwrap() //TODO: fixme + }; Self::boats_to_details(db, boats).await } diff --git a/src/model/logbook.rs b/src/model/logbook.rs index 735aecc..adca6f0 100644 --- a/src/model/logbook.rs +++ b/src/model/logbook.rs @@ -1,4 +1,4 @@ -use chrono::{Local, NaiveDateTime, TimeZone}; +use chrono::{NaiveDateTime, TimeZone}; use chrono_tz::Europe::Vienna; use rocket::FromForm; use serde::Serialize; @@ -196,7 +196,7 @@ ORDER BY departure DESC if let Some(arrival) = &log.arrival { let dep = NaiveDateTime::parse_from_str(&log.departure, "%Y-%m-%dT%H:%M").unwrap(); - let arr = NaiveDateTime::parse_from_str(&arrival, "%Y-%m-%dT%H:%M").unwrap(); + let arr = NaiveDateTime::parse_from_str(arrival, "%Y-%m-%dT%H:%M").unwrap(); if arr <= dep { return Err(LogbookCreateError::ArrivalNotAfterDeparture); } diff --git a/src/tera/log.rs b/src/tera/log.rs index 0e4c11d..738a26f 100644 --- a/src/tera/log.rs +++ b/src/tera/log.rs @@ -148,18 +148,18 @@ async fn create_logbook(db: &SqlitePool, data: Form, user: &User) -> F .await { Ok(_) => Flash::success(Redirect::to("/log"), "Ausfahrt erfolgreich hinzugefügt"), - Err(LogbookCreateError::BoatAlreadyOnWater) => Flash::error(Redirect::to("/log"), format!("Boot schon am Wasser")), - Err(LogbookCreateError::ShipmasterAlreadyOnWater) => Flash::error(Redirect::to("/log"), format!("Schiffsführer schon am Wasser")), + Err(LogbookCreateError::BoatAlreadyOnWater) => Flash::error(Redirect::to("/log"), "Boot schon am Wasser"), + Err(LogbookCreateError::ShipmasterAlreadyOnWater) => Flash::error(Redirect::to("/log"), "Schiffsführer schon am Wasser"), Err(LogbookCreateError::RowerAlreadyOnWater(rower)) => Flash::error(Redirect::to("/log"), format!("Ruderer {} schon am Wasser", rower.name)), - Err(LogbookCreateError::BoatLocked) => Flash::error(Redirect::to("/log"), format!("Boot gesperrt")), - Err(LogbookCreateError::BoatNotFound) => Flash::error(Redirect::to("/log"), format!("Boot gibt's ned")), + Err(LogbookCreateError::BoatLocked) => Flash::error(Redirect::to("/log"),"Boot gesperrt"), + Err(LogbookCreateError::BoatNotFound) => Flash::error(Redirect::to("/log"), "Boot gibt's ned"), Err(LogbookCreateError::TooManyRowers(expected, actual)) => Flash::error(Redirect::to("/log"), format!("Zu viele Ruderer (Boot fasst maximal {expected}, es wurden jedoch {actual} Ruderer ausgewählt)")), Err(LogbookCreateError::RowerCreateError(rower, e)) => Flash::error(Redirect::to("/log"), format!("Fehler bei Ruderer {rower}: {e}")), - Err(LogbookCreateError::SamePersonShipmasterAndRower) => Flash::error(Redirect::to("/log"), format!("Selbe Person als Schiffsführer und Ruderer ausgewählt")), - Err(LogbookCreateError::ArrivalSetButNoDistance) => Flash::error(Redirect::to("/log"), format!("Distanz notwendig, wenn Ankunftszeit angegeben wurde")), - Err(LogbookCreateError::ArrivalSetButNoDestination) => Flash::error(Redirect::to("/log"), format!("Ziel notwendig, wenn Ankunftszeit angegeben wurde")), - Err(LogbookCreateError::ArrivalNotAfterDeparture) => Flash::error(Redirect::to("/log"), format!("Ankunftszeit kann nicht vor der Abfahrtszeit sein")), - Err(LogbookCreateError::UserNotAllowedToUseBoat) => Flash::error(Redirect::to("/log"), format!("Schiffsführer darf dieses Boot nicht verwenden")), + Err(LogbookCreateError::SamePersonShipmasterAndRower) => Flash::error(Redirect::to("/log"), "Selbe Person als Schiffsführer und Ruderer ausgewählt"), + Err(LogbookCreateError::ArrivalSetButNoDistance) => Flash::error(Redirect::to("/log"), "Distanz notwendig, wenn Ankunftszeit angegeben wurde"), + Err(LogbookCreateError::ArrivalSetButNoDestination) => Flash::error(Redirect::to("/log"), "Ziel notwendig, wenn Ankunftszeit angegeben wurde"), + Err(LogbookCreateError::ArrivalNotAfterDeparture) => Flash::error(Redirect::to("/log"), "Ankunftszeit kann nicht vor der Abfahrtszeit sein"), + Err(LogbookCreateError::UserNotAllowedToUseBoat) => Flash::error(Redirect::to("/log"), "Schiffsführer darf dieses Boot nicht verwenden"), } } @@ -196,10 +196,10 @@ async fn home_logbook( match logbook.home(db, user, data.into_inner()).await { Ok(_) => Flash::success(Redirect::to("/log"), "Successfully updated log"), Err(LogbookUpdateError::TooManyRowers(expected, actual)) => Flash::error(Redirect::to("/log"), format!("Zu viele Ruderer (Boot fasst maximal {expected}, es wurden jedoch {actual} Ruderer ausgewählt)")), - Err(a) => {println!("{a:?}"); return Flash::error( + Err(_) => Flash::error( Redirect::to("/log"), format!("Logbook with ID {} could not be updated!", logbook_id), - )}, + ), } }