From 8df3adbfc3671ca954df1c66b009ffa3819ce5cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Taymans?= Date: Fri, 15 Dec 2017 18:50:31 +0100 Subject: [PATCH] [ADD] website_shift: Regular personal work page Add personal shift page for regular worker. --- beesdoo_website_shift/controllers/main.py | 20 +- .../views/shift_website_templates.xml | 303 +++++++++++++----- 2 files changed, 232 insertions(+), 91 deletions(-) diff --git a/beesdoo_website_shift/controllers/main.py b/beesdoo_website_shift/controllers/main.py index 9b2e4d6..f9ba9a6 100644 --- a/beesdoo_website_shift/controllers/main.py +++ b/beesdoo_website_shift/controllers/main.py @@ -98,15 +98,29 @@ class WebsiteShiftController(http.Controller): } ) - @http.route('/shift_template_regular_worker', auth='public', website=True) def shift_template_regular_worker(self, **kwargs): + # Get current user + cur_user = request.env['res.users'].browse(request.uid) + # Get all the task template template = request.env['beesdoo.shift.template'] task_templates = template.sudo().search([], order="planning_id, day_nb_id, start_time") - return request.render('beesdoo_website_shift.task_template', + # Get shifts where user is subscribed + now = datetime.now() + subscribed_shifts = request.env['beesdoo.shift.shift'].sudo().search( + [('start_time', '>', now.strftime("%Y-%m-%d %H:%M:%S")), + ('worker_id', '=', cur_user.partner_id.id)], + order="start_time, task_template_id, task_type_id", + ) + + return request.render( + 'beesdoo_website_shift.regular_worker', { + 'partner': cur_user.partner_id, + 'status': cur_user.partner_id.cooperative_status_ids, 'task_templates': task_templates, - 'float_to_time': float_to_time + 'float_to_time': float_to_time, + 'subscribed_shifts': subscribed_shifts, } ) diff --git a/beesdoo_website_shift/views/shift_website_templates.xml b/beesdoo_website_shift/views/shift_website_templates.xml index 90b9b5b..321ea93 100644 --- a/beesdoo_website_shift/views/shift_website_templates.xml +++ b/beesdoo_website_shift/views/shift_website_templates.xml @@ -49,10 +49,10 @@ - +