From 997cedee29d5526a7357d802f961d13c21cae83c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9my=20Taymans?=
Date: Thu, 18 Jan 2018 17:18:52 +0100
Subject: [PATCH] [FIX] webs_shift: Wrong display of date last shift
Fix the case when an irregular worker is in alert and that the date
before last shift is displayed.
The `date_before_last_shift` is renamed in `future_alert_start_time`.
This name better represent what this variable contains. It also explains
why this information does not have to be displayed when the worker is
already in alert mode as this date is the date in the future on which
the worker will be in alert.
---
beesdoo_website_shift/controllers/main.py | 14 ++++++++------
.../views/my_shift_website_templates.xml | 6 +++---
2 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/beesdoo_website_shift/controllers/main.py b/beesdoo_website_shift/controllers/main.py
index 83433de..1a156cd 100644
--- a/beesdoo_website_shift/controllers/main.py
+++ b/beesdoo_website_shift/controllers/main.py
@@ -144,15 +144,17 @@ class WebsiteShiftController(http.Controller):
irregular_enable_sign_up, nexturl
))
- # Compute date before which the worker is up to date
- today_date = fields.Date.from_string(cur_cooperative_status.today)
- delta = (today_date - fields.Date.from_string(cur_cooperative_status.irregular_start_date)).days
- date_before_last_shift = today_date + timedelta(days=(cur_cooperative_status.sr + 1) * PERIOD - delta % PERIOD)
- date_before_last_shift = date_before_last_shift.strftime('%Y-%m-%d')
+ future_alert_date = False
+ if not cur_cooperative_status.alert_start_time:
+ # Compute date before which the worker is up to date
+ today_date = fields.Date.from_string(cur_cooperative_status.today)
+ delta = (today_date - fields.Date.from_string(cur_cooperative_status.irregular_start_date)).days
+ future_alert_date = today_date + timedelta(days=(cur_cooperative_status.sr + 1) * PERIOD - delta % PERIOD)
+ future_alert_date = future_alert_date.strftime('%Y-%m-%d')
template_context.update(
{
- 'date_before_last_shift': date_before_last_shift,
+ 'future_alert_date': future_alert_date,
}
)
return template_context
diff --git a/beesdoo_website_shift/views/my_shift_website_templates.xml b/beesdoo_website_shift/views/my_shift_website_templates.xml
index 0b84832..a492a10 100644
--- a/beesdoo_website_shift/views/my_shift_website_templates.xml
+++ b/beesdoo_website_shift/views/my_shift_website_templates.xml
@@ -618,9 +618,9 @@