From 1e6f36e8e3e3e41b7fe4c869e91d683e3a80c34e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Taymans?= Date: Wed, 26 Aug 2020 17:52:25 +0200 Subject: [PATCH] [FIX] b_worker_status: compute status extempted --- .../models/cooperative_status.py | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/beesdoo_worker_status/models/cooperative_status.py b/beesdoo_worker_status/models/cooperative_status.py index 2b1db7c12..cf46d3656 100644 --- a/beesdoo_worker_status/models/cooperative_status.py +++ b/beesdoo_worker_status/models/cooperative_status.py @@ -162,14 +162,18 @@ def _get_regular_status(self): return "unsubscribed" # Check if exempted. Exempt end date is not required. if ( + # Start and end are defined self.temporary_exempt_start_date + and self.temporary_exempt_end_date + and self.today >= self.temporary_exempt_start_date + and self.today <= self.temporary_exempt_end_date + ) or ( + # Only start is defined + self.temporary_exempt_start_date + and not self.temporary_exempt_end_date and self.today >= self.temporary_exempt_start_date ): - if ( - not self.temporary_exempt_end_date - or self.today <= self.temporary_exempt_end_date - ): - return "exempted" + return "exempted" # Transition to alert sr < 0 or stay in alert sr < 0 or sc < 0 and # thus alert time is defined @@ -181,6 +185,7 @@ def _get_regular_status(self): <= add_days_delta(self.extension_start_time, grace_delay) ): return "extension" + if ( not ok and self.alert_start_time @@ -189,12 +194,14 @@ def _get_regular_status(self): > add_days_delta(self.extension_start_time, grace_delay) ): return "suspended" + if ( not ok and self.alert_start_time and self.today > add_days_delta(self.alert_start_time, alert_delay) ): return "suspended" + if (self.sr < 0) or (not ok and self.alert_start_time): return "alert" @@ -204,7 +211,6 @@ def _get_regular_status(self): and self.today >= self.holiday_start_time and self.today <= self.holiday_end_time ): - return "holiday" elif ok or (not self.alert_start_time and self.sr >= 0): return "ok" @@ -230,14 +236,18 @@ def _get_irregular_status(self): return "unsubscribed" # Check if exempted. Exempt end date is not required. elif ( + # Start and end are defined + self.temporary_exempt_start_date + and self.temporary_exempt_end_date + and self.today >= self.temporary_exempt_start_date + and self.today <= self.temporary_exempt_end_date + ) or ( + # Only start is defined self.temporary_exempt_start_date + and not self.temporary_exempt_end_date and self.today >= self.temporary_exempt_start_date ): - if ( - not self.temporary_exempt_end_date - or self.today <= self.temporary_exempt_end_date - ): - return "exempted" + return "exempted" # Transition to alert sr < 0 or stay in alert sr < 0 or sc < 0 and # thus alert time is defined elif (