diff --git a/beesdoo_website_shift/controllers/main.py b/beesdoo_website_shift/controllers/main.py index c3d9756..cc1655f 100644 --- a/beesdoo_website_shift/controllers/main.py +++ b/beesdoo_website_shift/controllers/main.py @@ -253,9 +253,11 @@ class WebsiteShiftController(http.Controller): """ return self.my_shift_worker_status() - def available_shift_irregular_worker(self, irregular_enable_sign_up=False, nexturl=""): + def available_shift_irregular_worker(self, irregular_enable_sign_up=False, + nexturl=""): """ - Return template variables for 'beesdoo_website_shift.available_shift_irregular_worker' template + Return template variables for + 'beesdoo_website_shift.available_shift_irregular_worker' template """ # Get current user cur_user = request.env['res.users'].browse(request.uid) @@ -278,12 +280,18 @@ class WebsiteShiftController(http.Controller): ) # Get config - irregular_shift_limit = int(request.env['ir.config_parameter'].get_param( - 'beesdoo_website_shift.irregular_shift_limit')) - highlight_rule = int(request.env['ir.config_parameter'].get_param( - 'beesdoo_website_shift.highlight_rule')) - hide_rule = int(request.env['ir.config_parameter'].get_param( - 'beesdoo_website_shift.hide_rule')) / 100.0 + irregular_shift_limit = int( + request.env['ir.config_parameter'] + .get_param('beesdoo_website_shift.irregular_shift_limit') + ) + highlight_rule_pc = int( + request.env['ir.config_parameter'] + .get_param('beesdoo_website_shift.highlight_rule_pc') + ) + hide_rule = int( + request.env['ir.config_parameter'] + .get_param('beesdoo_website_shift.hide_rule') + ) / 100.0 # Grouby task_template_id, if no task_template_id is specified # then group by start_time, if no start_time specified sort by @@ -307,15 +315,23 @@ class WebsiteShiftController(http.Controller): sub_shift.start_time == start_time and sub_shift.task_type_id == task_type) for sub_shift in subscribed_shifts) + # Check the necessary number of worker based on the + # highlight_rule_pc + has_enough_workers = free_space <= (task_template.worker_nb + * highlight_rule_pc) / 100 if free_space >= task_template.worker_nb * hide_rule: - shifts_count_subscribed.append([shift_list[0], free_space, is_subscribed]) + shifts_count_subscribed.append([ + shift_list[0], + free_space, + is_subscribed, + has_enough_workers, + ]) # Stop showing shifts if the limit is reached if irregular_shift_limit > 0 and nb_displayed_shift >= irregular_shift_limit: break return { 'shift_templates': shifts_count_subscribed, - 'highlight_rule': highlight_rule, 'nexturl': nexturl, 'irregular_enable_sign_up': irregular_enable_sign_up, } @@ -380,11 +396,11 @@ class WebsiteShiftController(http.Controller): # Set new date shift.start_time = self.add_days( fields.Datetime.from_string(main_shift.start_time), - days=i*PERIOD + days=i * PERIOD ) shift.end_time = self.add_days( fields.Datetime.from_string(main_shift.end_time), - days=i*PERIOD + days=i * PERIOD ) # Add the fictive shift to the list of shift subscribed_shifts.append(shift) diff --git a/beesdoo_website_shift/data/res_config_data.xml b/beesdoo_website_shift/data/res_config_data.xml index 55f661d..2b23c04 100644 --- a/beesdoo_website_shift/data/res_config_data.xml +++ b/beesdoo_website_shift/data/res_config_data.xml @@ -9,9 +9,9 @@ beesdoo_website_shift.irregular_shift_limit 0 - - beesdoo_website_shift.highlight_rule - 3 + + beesdoo_website_shift.highlight_rule_pc + 30 beesdoo_website_shift.hide_rule diff --git a/beesdoo_website_shift/i18n/fr_BE.po b/beesdoo_website_shift/i18n/fr_BE.po index 1ee98ac..34252a0 100644 --- a/beesdoo_website_shift/i18n/fr_BE.po +++ b/beesdoo_website_shift/i18n/fr_BE.po @@ -462,7 +462,7 @@ msgstr "S'inscrire" #. module: beesdoo_website_shift #: model:ir.ui.view,arch_db:beesdoo_website_shift.public_shift_irregular_worker msgid "Subscribe via" -msgstr "Nous avons spécialement besoin d'aide pour les shifts&nbsp; pour lesquels il y a au moins 3 places disponibles. Inscriptions via" +msgstr "Nous avons spécialement besoin d'aide pour les shifts surlignés en jaune. Inscriptions via" #. module: beesdoo_website_shift #: model:ir.ui.view,arch_db:beesdoo_website_shift.public_shift_template_regular_worker diff --git a/beesdoo_website_shift/models/res_config.py b/beesdoo_website_shift/models/res_config.py index e7e4910..867ed8b 100644 --- a/beesdoo_website_shift/models/res_config.py +++ b/beesdoo_website_shift/models/res_config.py @@ -8,17 +8,20 @@ from openerp import fields, models, api PARAMS = [ ('irregular_shift_limit', 'beesdoo_website_shift.irregular_shift_limit'), - ('highlight_rule', 'beesdoo_website_shift.highlight_rule'), + ('highlight_rule_pc', 'beesdoo_website_shift.highlight_rule_pc'), ('hide_rule', 'beesdoo_website_shift.hide_rule'), - ('irregular_enable_sign_up', 'beesdoo_website_shift.irregular_enable_sign_up'), - ('irregular_past_shift_limit', 'beesdoo_website_shift.irregular_past_shift_limit'), - ('regular_past_shift_limit', 'beesdoo_website_shift.regular_past_shift_limit'), - ('regular_next_shift_limit', 'beesdoo_website_shift.regular_next_shift_limit'), + ('irregular_enable_sign_up', + 'beesdoo_website_shift.irregular_enable_sign_up'), + ('irregular_past_shift_limit', + 'beesdoo_website_shift.irregular_past_shift_limit'), + ('regular_past_shift_limit' + , 'beesdoo_website_shift.regular_past_shift_limit'), + ('regular_next_shift_limit', + 'beesdoo_website_shift.regular_next_shift_limit'), ] class WebsiteShiftConfigSettings(models.TransientModel): - _name = 'beesdoo.website.shift.config.settings' _inherit = 'res.config.settings' @@ -26,11 +29,13 @@ class WebsiteShiftConfigSettings(models.TransientModel): irregular_shift_limit = fields.Integer( help="Maximum shift that will be shown" ) - highlight_rule = fields.Integer( - help="Treshold of available space in a shift that trigger the highlight of the shift" + highlight_rule_pc = fields.Integer( + help="Treshold (in %) of available space in a shift that trigger the " + "highlight of the shift" ) hide_rule = fields.Integer( - help="Treshold ((available space)/(max space)) in percentage of available space under wich the shift is hidden" + help="Treshold ((available space)/(max space)) in percentage of " + "available space under wich the shift is hidden" ) irregular_enable_sign_up = fields.Boolean( help="Enable shift sign up for irregular worker" @@ -58,46 +63,59 @@ class WebsiteShiftConfigSettings(models.TransientModel): @api.multi def get_default_irregular_shift_limit(self): return { - 'irregular_shift_limit': int(self.env['ir.config_parameter'].get_param( - 'beesdoo_website_shift.irregular_shift_limit')) + 'irregular_shift_limit': int( + self.env['ir.config_parameter'] + .get_param("beesdoo_website_shift.irregular_shift_limit") + ) } @api.multi - def get_default_highlight_rule(self): + def get_default_highlight_rule_pc(self): return { - 'highlight_rule': int(self.env['ir.config_parameter'].get_param('beesdoo_website_shift.highlight_rule')) + 'highlight_rule_pc': int( + self.env['ir.config_parameter'] + .get_param("beesdoo_website_shift.highlight_rule_pc") + ) } @api.multi def get_default_hide_rule(self): return { - 'hide_rule': int(self.env['ir.config_parameter'].get_param('beesdoo_website_shift.hide_rule')) + 'hide_rule': int(self.env['ir.config_parameter'].get_param( + 'beesdoo_website_shift.hide_rule')) } @api.multi def get_default_irregular_shift_sign_up(self): return { - 'irregular_enable_sign_up': literal_eval(self.env['ir.config_parameter'].get_param( - 'beesdoo_website_shift.irregular_enable_sign_up')) + 'irregular_enable_sign_up': + literal_eval(self.env['ir.config_parameter'].get_param( + 'beesdoo_website_shift.irregular_enable_sign_up')) } @api.multi def get_default_irregular_past_shift_limit(self): return { - 'irregular_past_shift_limit': int(self.env['ir.config_parameter'].get_param( - 'beesdoo_website_shift.irregular_past_shift_limit')) + 'irregular_past_shift_limit': int( + self.env['ir.config_parameter'] + .get_param("beesdoo_website_shift.irregular_past_shift_limit") + ) } @api.multi def get_default_regular_past_shift_limit(self): return { - 'regular_past_shift_limit': int(self.env['ir.config_parameter'].get_param( - 'beesdoo_website_shift.regular_past_shift_limit')) + 'regular_past_shift_limit': int( + self.env['ir.config_parameter'] + .get_param('beesdoo_website_shift.regular_past_shift_limit') + ) } @api.multi def get_default_regular_next_shift_limit(self): return { - 'regular_next_shift_limit': int(self.env['ir.config_parameter'].get_param( - 'beesdoo_website_shift.regular_next_shift_limit')) + 'regular_next_shift_limit': int( + self.env['ir.config_parameter'] + .get_param('beesdoo_website_shift.regular_next_shift_limit') + ) } diff --git a/beesdoo_website_shift/views/my_shift_website_templates.xml b/beesdoo_website_shift/views/my_shift_website_templates.xml index a3dde43..2d04299 100644 --- a/beesdoo_website_shift/views/my_shift_website_templates.xml +++ b/beesdoo_website_shift/views/my_shift_website_templates.xml @@ -380,7 +380,8 @@ - + +
@@ -427,7 +428,8 @@ - + + diff --git a/beesdoo_website_shift/views/res_config_views.xml b/beesdoo_website_shift/views/res_config_views.xml index 960c712..002971d 100644 --- a/beesdoo_website_shift/views/res_config_views.xml +++ b/beesdoo_website_shift/views/res_config_views.xml @@ -20,8 +20,8 @@
-