|
@ -135,6 +135,7 @@ class WebsiteShiftController(http.Controller): |
|
|
* the given shift exist |
|
|
* the given shift exist |
|
|
* the shift status is open |
|
|
* the shift status is open |
|
|
* the shift is free for subscription |
|
|
* the shift is free for subscription |
|
|
|
|
|
* the shift is starting in more than 20 minutes |
|
|
""" |
|
|
""" |
|
|
# Get current user |
|
|
# Get current user |
|
|
cur_user = request.env['res.users'].browse(request.uid) |
|
|
cur_user = request.env['res.users'].browse(request.uid) |
|
@ -143,12 +144,16 @@ class WebsiteShiftController(http.Controller): |
|
|
# Get config |
|
|
# Get config |
|
|
irregular_enable_sign_up = literal_eval(request.env['ir.config_parameter'].get_param( |
|
|
irregular_enable_sign_up = literal_eval(request.env['ir.config_parameter'].get_param( |
|
|
'beesdoo_website_shift.irregular_enable_sign_up')) |
|
|
'beesdoo_website_shift.irregular_enable_sign_up')) |
|
|
|
|
|
|
|
|
|
|
|
# Set start time limit |
|
|
|
|
|
start_time_limit = datetime.now() + timedelta(minutes = 20) |
|
|
|
|
|
shift_start_time = fields.Datetime.from_string(shift.start_time) |
|
|
request.session['success'] = False |
|
|
request.session['success'] = False |
|
|
|
|
|
|
|
|
if (irregular_enable_sign_up |
|
|
if (irregular_enable_sign_up |
|
|
and self.user_can_subscribe() |
|
|
and self.user_can_subscribe() |
|
|
and shift |
|
|
and shift |
|
|
and shift.state == "open" |
|
|
and shift.state == "open" |
|
|
|
|
|
and shift_start_time > start_time_limit |
|
|
and not shift.worker_id): |
|
|
and not shift.worker_id): |
|
|
shift.worker_id = cur_user.partner_id |
|
|
shift.worker_id = cur_user.partner_id |
|
|
request.session['success'] = True |
|
|
request.session['success'] = True |
|
|