Browse Source

[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.
pull/33/head
Rémy Taymans 6 years ago
parent
commit
997cedee29
  1. 14
      beesdoo_website_shift/controllers/main.py
  2. 6
      beesdoo_website_shift/views/my_shift_website_templates.xml

14
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

6
beesdoo_website_shift/views/my_shift_website_templates.xml

@ -618,9 +618,9 @@
<t t-esc="status.sr"/>
</p>
<p t-if="date_before_last_shift">
<label>Date Before Last Shift:</label>
<t t-esc="time.strftime('%A %d %B %Y', time.strptime(date_before_last_shift, '%Y-%m-%d'))"/>
<p t-if="future_alert_date">
<label>Future Date of Alert:</label>
<t t-esc="time.strftime('%A %d %B %Y', time.strptime(future_alert_date, '%Y-%m-%d'))"/>
</p>
<p t-if="status.irregular_absence_date">

Loading…
Cancel
Save