Enhance get_current_status logic to maintain 'completed' status and add TTL for push notifications
This commit is contained in:
+4
-4
@@ -72,6 +72,10 @@ def get_current_status(ausleihung, log_changes=False, user=None):
|
|||||||
if original_status == 'cancelled':
|
if original_status == 'cancelled':
|
||||||
return 'cancelled'
|
return 'cancelled'
|
||||||
|
|
||||||
|
# Wenn die Ausleihung bereits abgeschlossen ist, bleibt sie es
|
||||||
|
if original_status == 'completed':
|
||||||
|
return 'completed'
|
||||||
|
|
||||||
current_time = datetime.datetime.now()
|
current_time = datetime.datetime.now()
|
||||||
start_time = ausleihung.get('Start')
|
start_time = ausleihung.get('Start')
|
||||||
end_time = ausleihung.get('End')
|
end_time = ausleihung.get('End')
|
||||||
@@ -79,10 +83,6 @@ def get_current_status(ausleihung, log_changes=False, user=None):
|
|||||||
# Wenn kein Startdatum vorhanden ist, Status auf 'planned' setzen
|
# Wenn kein Startdatum vorhanden ist, Status auf 'planned' setzen
|
||||||
if not start_time:
|
if not start_time:
|
||||||
new_status = 'planned'
|
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
|
# Wenn die aktuelle Zeit vor dem Startdatum liegt, ist die Ausleihung geplant
|
||||||
elif current_time < start_time:
|
elif current_time < start_time:
|
||||||
# DEBUG: Log info wenn Booking noch lange in der Zukunft ist
|
# DEBUG: Log info wenn Booking noch lange in der Zukunft ist
|
||||||
|
|||||||
@@ -324,7 +324,8 @@ def _send_web_push_notification(subscription, payload):
|
|||||||
data=json.dumps(payload),
|
data=json.dumps(payload),
|
||||||
vapid_private_key=VAPID_PRIVATE_KEY,
|
vapid_private_key=VAPID_PRIVATE_KEY,
|
||||||
vapid_claims={'sub': VAPID_SUBJECT},
|
vapid_claims={'sub': VAPID_SUBJECT},
|
||||||
timeout=10
|
timeout=10,
|
||||||
|
ttl=3600 # Notification expires after 1 hour if device is offline
|
||||||
)
|
)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|||||||
Reference in New Issue
Block a user