Compare commits

...

3 Commits

Author SHA1 Message Date
127d9784ad Merge pull request 'external-cox' (#653) from external-cox into staging
Some checks failed
CI/CD Pipeline / deploy-staging (push) Blocked by required conditions
CI/CD Pipeline / deploy-main (push) Blocked by required conditions
CI/CD Pipeline / test (push) Has been cancelled
Reviewed-on: #653
2024-07-28 07:30:59 +02:00
bf4ea502d3 allow external cox; Fix #650
Some checks failed
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
CI/CD Pipeline / test (push) Has been cancelled
2024-07-28 07:29:44 +02:00
c13dfdaa77 Merge pull request 'fix spacing in roles' (#652) from fix-spacing into main
Some checks failed
CI/CD Pipeline / deploy-staging (push) Blocked by required conditions
CI/CD Pipeline / deploy-main (push) Blocked by required conditions
CI/CD Pipeline / test (push) Has been cancelled
Reviewed-on: #652
2024-07-28 07:14:29 +02:00
2 changed files with 25 additions and 1 deletions

View File

@ -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()))?;

View File

@ -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:?})!"),