Compare commits

...

3 Commits

Author SHA1 Message Date
8aca437eb3 Merge pull request 'fix' (#655) from fix into staging
Some checks failed
CI/CD Pipeline / test (push) Failing after 1m43s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped
Reviewed-on: #655
2024-07-28 07:37:57 +02:00
cd1bf12e68 ext person can also be shipmaster (and not cox)
Some checks failed
CI/CD Pipeline / test (push) Failing after 1m41s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped
2024-07-28 07:36:57 +02:00
5f7591f52a Merge pull request 'allow external cox; Fix #650' (#654) from external-cox into main
Some checks are pending
CI/CD Pipeline / test (push) Waiting to run
CI/CD Pipeline / deploy-staging (push) Blocked by required conditions
CI/CD Pipeline / deploy-main (push) Blocked by required conditions
Reviewed-on: #654
2024-07-28 07:31:02 +02:00
2 changed files with 19 additions and 10 deletions

View File

@ -127,7 +127,7 @@ pub enum LogbookUpdateError {
OnlyAllowedToEndTripsEndingToday,
TooFast(i64, i64),
AlreadyFinalized,
ExternalSteeringPersonMustSteer,
ExternalSteeringPersonMustSteerOrShipmaster,
}
#[derive(Debug, PartialEq)]
@ -153,7 +153,7 @@ pub enum LogbookCreateError {
CantChangeHandoperatableStatusForThisBoat,
TooFast(i64, i64),
AlreadyFinalized,
ExternalSteeringPersonMustSteer,
ExternalSteeringPersonMustSteerOrShipmaster,
}
impl From<LogbookUpdateError> for LogbookCreateError {
@ -421,9 +421,13 @@ ORDER BY departure DESC
}
if user.name == "Externe Steuerperson" {
if let Some(steering_id) = log.steering_person {
if steering_id != user.id {
return Err(LogbookCreateError::ExternalSteeringPersonMustSteer);
if let (Some(steering_id), Some(shipmaster_id)) =
(log.steering_person, log.shipmaster)
{
if steering_id != user.id && shipmaster_id != user.id {
return Err(
LogbookCreateError::ExternalSteeringPersonMustSteerOrShipmaster,
);
}
}
}
@ -623,12 +627,17 @@ 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);
if let (Some(steering_id), Some(shipmaster_id)) =
(log.steering_person, log.shipmaster)
{
if steering_id != user.id && shipmaster_id != user.id {
return Err(
LogbookUpdateError::ExternalSteeringPersonMustSteerOrShipmaster,
);
}
}
}
Rower::create(db, self.id, *rower)
.await
.map_err(|e| LogbookUpdateError::RowerCreateError(*rower, e.to_string()))?;

View File

@ -231,7 +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!"),
Err(LogbookCreateError::ExternalSteeringPersonMustSteerOrShipmaster) => Flash::error(Redirect::to("/log"), "Wenn du eine 'Externe Steuerperson' hinzufügst, muss diese steuern oder Schiffsführer sein!"),
}
}
@ -341,7 +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(LogbookUpdateError::ExternalSteeringPersonMustSteerOrShipmaster) => Flash::error(Redirect::to("/log"), "Wenn du eine 'Externe Steuerperson' hinzufügst, muss diese steuern oder Schiffsführer sein!"),
Err(e) => Flash::error(
Redirect::to("/log"),
format!("Eintrag {logbook_id} konnte nicht abgesendet werden (Fehler: {e:?})!"),