From be6d3229a475cc1b92d808934e5fd835a533c104 Mon Sep 17 00:00:00 2001
From: philipp <philipp@hofer.link>
Date: Fri, 23 Aug 2024 12:26:08 +0200
Subject: [PATCH] allow retroactively adding logbook entrie

---
 src/model/logbook.rs | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/model/logbook.rs b/src/model/logbook.rs
index a45a3cc..f52fb03 100644
--- a/src/model/logbook.rs
+++ b/src/model/logbook.rs
@@ -594,8 +594,14 @@ ORDER BY departure DESC
         let today = Local::now().date_naive();
         let day_diff = today - arr.date();
         let day_diff = day_diff.num_days();
-        if day_diff >= 7 && !user.has_role_tx(db, "admin").await {
-            return Err(LogbookUpdateError::OnlyAllowedToEndTripsEndingToday);
+        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);
+            }
         }
         if day_diff < 0 && !user.has_role_tx(db, "admin").await {
             return Err(LogbookUpdateError::OnlyAllowedToEndTripsEndingToday);