Browse Source

[ADD] website_shift: Feedback when subscribing

Add a feedback to the user about the successfulness of the subscription.
pull/43/head
Rémy Taymans 6 years ago
parent
commit
3de8f78cf1
  1. 9
      beesdoo_website_shift/controllers/main.py
  2. 16
      beesdoo_website_shift/views/my_shift_website_templates.xml

9
beesdoo_website_shift/controllers/main.py

@ -77,11 +77,13 @@ class WebsiteShiftController(http.Controller):
irregular_enable_sign_up = literal_eval(request.env['ir.config_parameter'].get_param(
'beesdoo_website_shift.irregular_enable_sign_up'))
request.session['success'] = False
if (irregular_enable_sign_up
and cur_user.partner_id.working_mode == 'irregular'
and shift
and not shift.worker_id):
shift.worker_id = cur_user.partner_id
request.session['success'] = True
return request.redirect(kw['nexturl'])
@http.route('/shift_irregular_worker', auth='public', website=True)
@ -138,6 +140,13 @@ class WebsiteShiftController(http.Controller):
irregular_enable_sign_up, nexturl
))
# Add feedback about the success or the fail of the subscription
template_context['back_from_subscription'] = False
if 'success' in request.session:
template_context['back_from_subscription'] = True
template_context['success'] = request.session.get('success')
del request.session['success']
return template_context
def my_shift_regular_worker(self):

16
beesdoo_website_shift/views/my_shift_website_templates.xml

@ -757,6 +757,22 @@
<div class="col-xs-12 col-md-8">
<div t-if="back_from_subscription"
role="alert"
t-att-class="'alert alert-%s alert-dismissible' % ('success' if success else 'danger',)">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<t t-if="success">
<strong>Success!</strong> Your subscription has succeded.
</t>
<t t-if="not success">
<strong>Failed!</strong> Your subscription has failed. Someone
subscribed before you or the shift was deleted. Try again in a
moment.
</t>
</div>
<t t-call="beesdoo_website_shift.my_shift_next_shifts"/>
<section class="wrap">

Loading…
Cancel
Save