Browse Source

[ADD] b_w_shift : prevent subscription 20 min before start

pull/143/head
Elouan Le Bars 5 years ago
parent
commit
6cf25a2f68
  1. 7
      beesdoo_website_shift/controllers/main.py
  2. 2
      beesdoo_website_shift/i18n/fr_BE.po
  3. 4
      beesdoo_website_shift/views/my_shift_website_templates.xml

7
beesdoo_website_shift/controllers/main.py

@ -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

2
beesdoo_website_shift/i18n/fr_BE.po

@ -167,7 +167,7 @@ msgstr "Appliquer"
#. module: beesdoo_website_shift #. module: beesdoo_website_shift
#: model:ir.ui.view,arch_db:beesdoo_website_shift.available_shift_irregular_worker #: 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 ?" msgstr "Etes-vous sûr de vouloir vous inscrire à ce shift ?"
#. module: beesdoo_website_shift #. module: beesdoo_website_shift

4
beesdoo_website_shift/views/my_shift_website_templates.xml

@ -480,7 +480,7 @@
<span aria-hidden="true">×</span> <span aria-hidden="true">×</span>
</button> </button>
<h4 class="modal-title" t-att-id="'subscribe-shift-%s-label' % shift.id"> <h4 class="modal-title" t-att-id="'subscribe-shift-%s-label' % shift.id">
Are you shure you want to subscribe to this shift?
Please confirm subscription
</h4> </h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
@ -901,6 +901,8 @@
<strong>Failed!</strong> Your subscription has failed. Someone <strong>Failed!</strong> Your subscription has failed. Someone
subscribed before you or the shift was deleted. Try again in a subscribed before you or the shift was deleted. Try again in a
moment. moment.
Please note that you can't subscribe 20 minutes before the shift.
</t> </t>
</div> </div>

Loading…
Cancel
Save