fix #655
@ -127,6 +127,7 @@ pub enum LogbookUpdateError {
|
||||
OnlyAllowedToEndTripsEndingToday,
|
||||
TooFast(i64, i64),
|
||||
AlreadyFinalized,
|
||||
ExternalSteeringPersonMustSteer,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
@ -152,6 +153,7 @@ pub enum LogbookCreateError {
|
||||
CantChangeHandoperatableStatusForThisBoat,
|
||||
TooFast(i64, i64),
|
||||
AlreadyFinalized,
|
||||
ExternalSteeringPersonMustSteer,
|
||||
}
|
||||
|
||||
impl From<LogbookUpdateError> for LogbookCreateError {
|
||||
@ -177,6 +179,9 @@ impl From<LogbookUpdateError> for LogbookCreateError {
|
||||
}
|
||||
LogbookUpdateError::TooFast(km, min) => LogbookCreateError::TooFast(km, min),
|
||||
LogbookUpdateError::AlreadyFinalized => LogbookCreateError::AlreadyFinalized,
|
||||
LogbookUpdateError::ExternalSteeringPersonMustSteer => {
|
||||
LogbookCreateError::ExternalSteeringPersonMustSteer
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -414,6 +419,14 @@ ORDER BY departure DESC
|
||||
if user.on_water(db).await {
|
||||
return Err(LogbookCreateError::RowerAlreadyOnWater(Box::new(user)));
|
||||
}
|
||||
|
||||
if user.name == "Externe Steuerperson" {
|
||||
if let Some(steering_id) = log.steering_person {
|
||||
if steering_id != user.id {
|
||||
return Err(LogbookCreateError::ExternalSteeringPersonMustSteer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !boat.shipmaster_allowed(db, created_by_user).await {
|
||||
@ -609,6 +622,13 @@ ORDER BY departure DESC
|
||||
|
||||
self.remove_rowers(db).await;
|
||||
for rower in &log.rowers {
|
||||
if user.name == "Externe Steuerperson" {
|
||||
if let Some(steering_id) = log.steering_person {
|
||||
if steering_id != user.id {
|
||||
return Err(LogbookUpdateError::ExternalSteeringPersonMustSteer);
|
||||
}
|
||||
}
|
||||
}
|
||||
Rower::create(db, self.id, *rower)
|
||||
.await
|
||||
.map_err(|e| LogbookUpdateError::RowerCreateError(*rower, e.to_string()))?;
|
||||
|
@ -68,7 +68,9 @@ async fn index(
|
||||
)
|
||||
.await;
|
||||
users.retain(|u| {
|
||||
u.roles.contains(&"Donau Linz".into()) || u.roles.contains(&"scheckbuch".into())
|
||||
u.roles.contains(&"Donau Linz".into())
|
||||
|| u.roles.contains(&"scheckbuch".into())
|
||||
|| u.user.name == "Externe Steuerperson"
|
||||
});
|
||||
|
||||
let logtypes = LogType::all(db).await;
|
||||
@ -229,6 +231,7 @@ async fn create_logbook(
|
||||
Err(LogbookCreateError::CantChangeHandoperatableStatusForThisBoat) => Flash::error(Redirect::to("/log"), "Handsteuer-Status dieses Boots kann nicht verändert werden."),
|
||||
Err(LogbookCreateError::TooFast(km, min)) => Flash::error(Redirect::to("/log"), format!("KM zu groß für die eingegebene Dauer ({km} km in {min} Minuten). Bitte überprüfe deine Start- und Endzeit und versuche es erneut.")),
|
||||
Err(LogbookCreateError::AlreadyFinalized) => Flash::error(Redirect::to("/log"), "Logbucheintrag wurde bereits abgeschlossen."),
|
||||
Err(LogbookCreateError::ExternalSteeringPersonMustSteer) => Flash::error(Redirect::to("/log"), "Wenn du eine 'Externe Steuerperson' hinzufügst, muss diese steuern!"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -338,6 +341,7 @@ async fn home_logbook(
|
||||
Err(LogbookUpdateError::OnlyAllowedToEndTripsEndingToday) => Flash::error(Redirect::to("/log"), "Nur Ausfahrten, die heute enden dürfen eingetragen werden. Für einen Nachtrag schreibe alle Daten Philipp (Tel. nr. siehe Signal oder it@rudernlinz.at)."),
|
||||
Err(LogbookUpdateError::TooFast(km, min)) => Flash::error(Redirect::to("/log"), format!("KM zu groß für die eingegebene Dauer ({km} km in {min} Minuten). Bitte überprüfe deine Start- und Endzeit und versuche es erneut.")),
|
||||
Err(LogbookUpdateError::AlreadyFinalized) => Flash::error(Redirect::to("/log"), "Logbucheintrag wurde bereits abgeschlossen."),
|
||||
Err(LogbookUpdateError::ExternalSteeringPersonMustSteer) => Flash::error(Redirect::to("/log"), "Wenn du eine 'Externe Steuerperson' hinzufügst, muss diese steuern!"),
|
||||
Err(e) => Flash::error(
|
||||
Redirect::to("/log"),
|
||||
format!("Eintrag {logbook_id} konnte nicht abgesendet werden (Fehler: {e:?})!"),
|
||||
|
Loading…
Reference in New Issue
Block a user