Browse Source

[IMP] website_shift: Future alert date

The future alert date has moved to beesdoo_shift module. So we use this
one instead of re-compute it in the controller.
pull/43/head
Rémy Taymans 6 years ago
parent
commit
63440c5375
  1. 21
      beesdoo_website_shift/controllers/main.py
  2. 8
      beesdoo_website_shift/views/my_shift_website_templates.xml

21
beesdoo_website_shift/controllers/main.py

@ -5,7 +5,6 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from ast import literal_eval
from copy import copy
from datetime import datetime, timedelta
from itertools import groupby
@ -14,8 +13,7 @@ from openerp.http import request
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT as DATETIME_FORMAT
from openerp.addons.beesdoo_shift.models.planning import float_to_time
PERIOD = 28 # TODO: use the same constant as in 'beesdoo_shift'
from openerp.addons.beesdoo_shift.models.cooperative_status import PERIOD
class WebsiteShiftController(http.Controller):
@ -126,10 +124,6 @@ class WebsiteShiftController(http.Controller):
"""
Return template variables for 'beesdoo_website_shift.my_shift_irregular_worker' template
"""
# Get current user
cur_user = request.env['res.users'].browse(request.uid)
cur_cooperative_status = cur_user.partner_id.cooperative_status_ids
# Get config
irregular_enable_sign_up = literal_eval(request.env['ir.config_parameter'].get_param(
'beesdoo_website_shift.irregular_enable_sign_up'))
@ -144,19 +138,6 @@ class WebsiteShiftController(http.Controller):
irregular_enable_sign_up, nexturl
))
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(
{
'future_alert_date': future_alert_date,
}
)
return template_context
def my_shift_regular_worker(self):

8
beesdoo_website_shift/views/my_shift_website_templates.xml

@ -602,7 +602,7 @@
<section class="wrap">
<div class="container">
<div class="row">
<div class="col-xs-12 col-md-4 pull-right">
<div class="col-xs-12 col-md-4 pull-right text-justify">
<t t-call="beesdoo_website_shift.my_shift_worker_status_title"/>
@ -730,9 +730,9 @@
<t t-esc="status.sr"/>
</p>
<p t-if="future_alert_date">
<p t-if="status.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'))"/>
<t t-esc="time.strftime('%A %d %B %Y', time.strptime(status.future_alert_date, '%Y-%m-%d'))"/>
</p>
<p t-if="status.irregular_absence_date">
@ -776,7 +776,7 @@
<section class="wrap">
<div class="container">
<div class="row">
<div class="col-xs-12 col-sm-6">
<div class="col-xs-12 col-sm-6 text-justify">
<p>
Please, subscribe, in priority, to the highlighted shifts. To sign up to a shift click on the
subscribe button. Notice that you can not unsubscribe online. To unsubscribe to a shift, please,

Loading…
Cancel
Save