Browse Source

[FIX] b_worker_status: compute status extempted

pull/169/head 12.0-2020-08-26.00
Rémy Taymans 4 years ago
parent
commit
1e6f36e8e3
  1. 28
      beesdoo_worker_status/models/cooperative_status.py

28
beesdoo_worker_status/models/cooperative_status.py

@ -162,12 +162,16 @@ class CooperativeStatus(models.Model):
return "unsubscribed" return "unsubscribed"
# Check if exempted. Exempt end date is not required. # Check if exempted. Exempt end date is not required.
if ( if (
# Start and end are defined
self.temporary_exempt_start_date 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 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"
@ -181,6 +185,7 @@ class CooperativeStatus(models.Model):
<= add_days_delta(self.extension_start_time, grace_delay) <= add_days_delta(self.extension_start_time, grace_delay)
): ):
return "extension" return "extension"
if ( if (
not ok not ok
and self.alert_start_time and self.alert_start_time
@ -189,12 +194,14 @@ class CooperativeStatus(models.Model):
> add_days_delta(self.extension_start_time, grace_delay) > add_days_delta(self.extension_start_time, grace_delay)
): ):
return "suspended" return "suspended"
if ( if (
not ok not ok
and self.alert_start_time and self.alert_start_time
and self.today > add_days_delta(self.alert_start_time, alert_delay) and self.today > add_days_delta(self.alert_start_time, alert_delay)
): ):
return "suspended" return "suspended"
if (self.sr < 0) or (not ok and self.alert_start_time): if (self.sr < 0) or (not ok and self.alert_start_time):
return "alert" return "alert"
@ -204,7 +211,6 @@ class CooperativeStatus(models.Model):
and self.today >= self.holiday_start_time and self.today >= self.holiday_start_time
and self.today <= self.holiday_end_time and self.today <= self.holiday_end_time
): ):
return "holiday" return "holiday"
elif ok or (not self.alert_start_time and self.sr >= 0): elif ok or (not self.alert_start_time and self.sr >= 0):
return "ok" return "ok"
@ -230,12 +236,16 @@ class CooperativeStatus(models.Model):
return "unsubscribed" return "unsubscribed"
# Check if exempted. Exempt end date is not required. # Check if exempted. Exempt end date is not required.
elif ( elif (
# Start and end are defined
self.temporary_exempt_start_date 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 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 # Transition to alert sr < 0 or stay in alert sr < 0 or sc < 0 and

Loading…
Cancel
Save