diff --git a/src/model/boat.rs b/src/model/boat.rs index 4106393..115acec 100644 --- a/src/model/boat.rs +++ b/src/model/boat.rs @@ -21,9 +21,9 @@ pub struct Boat { pub boatbuilder: Option, pub default_destination: Option, #[serde(default = "bool::default")] - convert_handoperated_possible: bool, + pub convert_handoperated_possible: bool, #[serde(default = "bool::default")] - default_shipmaster_only_steering: bool, + pub default_shipmaster_only_steering: bool, #[serde(default = "bool::default")] skull: bool, #[serde(default = "bool::default")] diff --git a/src/model/logbook.rs b/src/model/logbook.rs index 5d83f12..156ad8e 100644 --- a/src/model/logbook.rs +++ b/src/model/logbook.rs @@ -126,6 +126,7 @@ pub enum LogbookCreateError { NotYourEntry, ArrivalSetButNotRemainingTwo, OnlyAllowedToEndTripsEndingToday, + CantChangeHandoperatableStatusForThisBoat, } impl From for LogbookCreateError { @@ -302,6 +303,12 @@ ORDER BY departure DESC return Err(LogbookCreateError::BoatNotFound); }; + if log.shipmaster_only_steering != boat.default_shipmaster_only_steering { + if !boat.convert_handoperated_possible { + return Err(LogbookCreateError::CantChangeHandoperatableStatusForThisBoat); + } + } + if boat.amount_seats == 1 && log.rowers.is_empty() { log.rowers = vec![created_by_user.id]; } diff --git a/src/tera/log.rs b/src/tera/log.rs index 241f36c..2c618b0 100644 --- a/src/tera/log.rs +++ b/src/tera/log.rs @@ -214,6 +214,7 @@ async fn create_logbook( Err(LogbookCreateError::NotYourEntry) => Flash::error(Redirect::to("/log"), "Nicht deine Ausfahrt!"), Err(LogbookCreateError::ArrivalSetButNotRemainingTwo) => Flash::error(Redirect::to("/log"), "Ankunftszeit gesetzt aber nicht Distanz + Strecke"), Err(LogbookCreateError::OnlyAllowedToEndTripsEndingToday) => Flash::error(Redirect::to("/log"), "Nur Ausfahrten, die in der letzten Woche enden dürfen eingetragen werden. Für einen Nachtrag schreibe alle Daten Philipp (Tel. nr. siehe Signal oder it@rudernlinz.at)."), + Err(LogbookCreateError::CantChangeHandoperatableStatusForThisBoat) => Flash::error(Redirect::to("/log"), "Handsteuer-Status dieses Boots kann nicht verändert werden."), } }