From 84ac9e812ad9510d928256a33ec16e4ac5072dc4 Mon Sep 17 00:00:00 2001 From: AIIrondev Date: Sun, 19 Apr 2026 16:57:35 +0200 Subject: [PATCH] Enhance get_current_status logic to maintain 'completed' status and add TTL for push notifications --- Web/ausleihung.py | 8 ++++---- Web/push_notifications.py | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Web/ausleihung.py b/Web/ausleihung.py index 09f051d..ebf9076 100755 --- a/Web/ausleihung.py +++ b/Web/ausleihung.py @@ -71,6 +71,10 @@ def get_current_status(ausleihung, log_changes=False, user=None): # Bei stornierten Ausleihungen bleibt der Status immer storniert if original_status == 'cancelled': return 'cancelled' + + # Wenn die Ausleihung bereits abgeschlossen ist, bleibt sie es + if original_status == 'completed': + return 'completed' current_time = datetime.datetime.now() start_time = ausleihung.get('Start') @@ -79,10 +83,6 @@ def get_current_status(ausleihung, log_changes=False, user=None): # Wenn kein Startdatum vorhanden ist, Status auf 'planned' setzen if not start_time: new_status = 'planned' - # Wenn die Ausleihung als 'completed' markiert wurde und ein Enddatum hat, - # bleibt sie bei 'completed' - elif original_status == 'completed' and end_time: - new_status = 'completed' # Wenn die aktuelle Zeit vor dem Startdatum liegt, ist die Ausleihung geplant elif current_time < start_time: # DEBUG: Log info wenn Booking noch lange in der Zukunft ist diff --git a/Web/push_notifications.py b/Web/push_notifications.py index 4cfe7f6..a87dd77 100644 --- a/Web/push_notifications.py +++ b/Web/push_notifications.py @@ -324,7 +324,8 @@ def _send_web_push_notification(subscription, payload): data=json.dumps(payload), vapid_private_key=VAPID_PRIVATE_KEY, vapid_claims={'sub': VAPID_SUBJECT}, - timeout=10 + timeout=10, + ttl=3600 # Notification expires after 1 hour if device is offline ) return True