From 873d9dd59e593f3e92b19a77a469b552fc298a0a Mon Sep 17 00:00:00 2001 From: Elouan Le Bars Date: Thu, 5 Dec 2019 13:54:06 +0100 Subject: [PATCH] [ADD] b_w_shift : prevent subscription 20 min before start --- beesdoo_website_shift/controllers/main.py | 7 ++++++- beesdoo_website_shift/i18n/fr_BE.po | 2 +- beesdoo_website_shift/views/my_shift_website_templates.xml | 4 +++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/beesdoo_website_shift/controllers/main.py b/beesdoo_website_shift/controllers/main.py index cdb502e..a3f4e92 100644 --- a/beesdoo_website_shift/controllers/main.py +++ b/beesdoo_website_shift/controllers/main.py @@ -135,6 +135,7 @@ class WebsiteShiftController(http.Controller): * the given shift exist * the shift status is open * the shift is free for subscription + * the shift is starting in more than 20 minutes """ # Get current user cur_user = request.env['res.users'].browse(request.uid) @@ -143,12 +144,16 @@ class WebsiteShiftController(http.Controller): # Get config irregular_enable_sign_up = literal_eval(request.env['ir.config_parameter'].get_param( '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 + if (irregular_enable_sign_up and self.user_can_subscribe() and shift and shift.state == "open" + and shift_start_time > start_time_limit and not shift.worker_id): shift.worker_id = cur_user.partner_id request.session['success'] = True diff --git a/beesdoo_website_shift/i18n/fr_BE.po b/beesdoo_website_shift/i18n/fr_BE.po index 34252a0..219d88e 100644 --- a/beesdoo_website_shift/i18n/fr_BE.po +++ b/beesdoo_website_shift/i18n/fr_BE.po @@ -167,7 +167,7 @@ msgstr "Appliquer" #. module: beesdoo_website_shift #: model:ir.ui.view,arch_db:beesdoo_website_shift.available_shift_irregular_worker -msgid "Are you shure you want to subscribe to this shift?" +msgid "Please confirm subscription" msgstr "Etes-vous sûr de vouloir vous inscrire à ce shift ?" #. module: beesdoo_website_shift diff --git a/beesdoo_website_shift/views/my_shift_website_templates.xml b/beesdoo_website_shift/views/my_shift_website_templates.xml index c73d475..56356c1 100644 --- a/beesdoo_website_shift/views/my_shift_website_templates.xml +++ b/beesdoo_website_shift/views/my_shift_website_templates.xml @@ -480,7 +480,7 @@