Skip to content

Commit

Permalink
[FIX] b_worker_status: compute status extempted
Browse files Browse the repository at this point in the history
  • Loading branch information
remytms committed Aug 26, 2020
1 parent 4f4ee67 commit 1e6f36e
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions beesdoo_worker_status/models/cooperative_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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"

Expand All @@ -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"
Expand All @@ -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 (
Expand Down

0 comments on commit 1e6f36e

Please sign in to comment.