From 30a5fc707eb4d7c434b30bf37f1865214bb7df1a Mon Sep 17 00:00:00 2001 From: Thibault Francois Date: Wed, 12 Aug 2020 18:24:14 +0200 Subject: [PATCH] [FIX] can unsubscribe delta is between date in the future and now not the opposite To get the full timedelta in hours we should get the days number and the seconds --- macavrac_base/models/planning.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/macavrac_base/models/planning.py b/macavrac_base/models/planning.py index 5e3d57d..684b122 100644 --- a/macavrac_base/models/planning.py +++ b/macavrac_base/models/planning.py @@ -64,7 +64,8 @@ class Task(models.Model): if now > rec.start_time or rec.state != 'open': rec.can_unsubscribe = False else: - delta = (now - rec.start_time).seconds / 3600.0 + delta = (rec.start_time - now) + delta = delta.seconds / 3600.0 + delta.days * 24 rec.can_unsubscribe = delta >= max_hours