Merge pull request 'allow retroactively adding logbook entrie' (#711) from allow-retro-logbookentry into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 10m52s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 8m12s

Reviewed-on: #711
This commit is contained in:
philipp 2024-08-23 12:26:45 +02:00
commit 0b46cbf8db

View File

@ -594,9 +594,15 @@ ORDER BY departure DESC
let today = Local::now().date_naive(); let today = Local::now().date_naive();
let day_diff = today - arr.date(); let day_diff = today - arr.date();
let day_diff = day_diff.num_days(); let day_diff = day_diff.num_days();
if day_diff >= 7 && !user.has_role_tx(db, "admin").await { if day_diff >= 7 {
if !user.has_role_tx(db, "admin").await
&& !user
.has_role_tx(db, "allow-retroactive-logbookentries")
.await
{
return Err(LogbookUpdateError::OnlyAllowedToEndTripsEndingToday); return Err(LogbookUpdateError::OnlyAllowedToEndTripsEndingToday);
} }
}
if day_diff < 0 && !user.has_role_tx(db, "admin").await { if day_diff < 0 && !user.has_role_tx(db, "admin").await {
return Err(LogbookUpdateError::OnlyAllowedToEndTripsEndingToday); return Err(LogbookUpdateError::OnlyAllowedToEndTripsEndingToday);
} }