Browse Source

[CHG] b_w_shift: Configure highlight of task template

Task templates are now highlighted based on a highlight rule.
pull/105/head
Rémy Taymans 5 years ago
committed by Elouan
parent
commit
a956c98920
  1. 2
      beesdoo_website_shift/__openerp__.py
  2. 18
      beesdoo_website_shift/controllers/main.py
  3. 4
      beesdoo_website_shift/data/res_config_data.xml
  4. 15
      beesdoo_website_shift/models/res_config.py
  5. 13
      beesdoo_website_shift/views/shift_website_templates.xml

2
beesdoo_website_shift/__openerp__.py

@ -16,7 +16,7 @@
'author': 'Rémy Taymans',
'license': 'AGPL-3',
'version': '9.0.2.2.0',
'version': '9.0.2.3.0',
'website': "https://github.com/beescoop/Obeesdoo",
'category': 'Cooperative management',

18
beesdoo_website_shift/controllers/main.py

@ -184,10 +184,26 @@ class WebsiteShiftController(http.Controller):
template = request.env['beesdoo.shift.template']
task_templates = template.sudo().search([], order="planning_id, day_nb_id, start_time")
# Get config
regular_highlight_rule = literal_eval(
request.env['ir.config_parameter'].get_param(
'beesdoo_website_shift.regular_highlight_rule'
)
)
task_tpls_data = []
for task_tpl in task_templates:
has_enough_workers = (
task_tpl.remaining_worker <= (
task_tpl.worker_nb * regular_highlight_rule / 100
)
)
task_tpls_data.append((task_tpl, has_enough_workers))
return request.render(
'beesdoo_website_shift.public_shift_template_regular_worker',
{
'task_templates': task_templates,
'task_tpls_data': task_tpls_data,
'float_to_time': float_to_time,
}
)

4
beesdoo_website_shift/data/res_config_data.xml

@ -33,5 +33,9 @@
<field name="key">beesdoo_website_shift.regular_next_shift_limit</field>
<field name="value">13</field>
</record>
<record id="beesdoo_website_shift.regular_highlight_rule" model="ir.config_parameter">
<field name="key">beesdoo_website_shift.regular_highlight_rule</field>
<field name="value">20</field>
</record>
</data>
</openerp>

15
beesdoo_website_shift/models/res_config.py

@ -18,6 +18,8 @@ PARAMS = [
'beesdoo_website_shift.regular_past_shift_limit'),
('regular_next_shift_limit',
'beesdoo_website_shift.regular_next_shift_limit'),
('regular_highlight_rule',
'beesdoo_website_shift.regular_highlight_rule'),
]
@ -51,6 +53,10 @@ class WebsiteShiftConfigSettings(models.TransientModel):
regular_next_shift_limit = fields.Integer(
help="Maximun number of next shift that will be shown"
)
regular_highlight_rule = fields.Integer(
help="Treshold (in %) of available space in a shift that trigger the "
"the highlight of a shift template."
)
@api.multi
def set_params(self):
@ -119,3 +125,12 @@ class WebsiteShiftConfigSettings(models.TransientModel):
.get_param('beesdoo_website_shift.regular_next_shift_limit')
)
}
@api.multi
def get_default_regular_highlight_rule(self):
return {
'regular_next_shift_limit': int(
self.env['ir.config_parameter']
.get_param('beesdoo_website_shift.regular_highlight_rule')
)
}

13
beesdoo_website_shift/views/shift_website_templates.xml

@ -64,8 +64,11 @@
<div class="oe_structure"/>
<div class="visible-xs" t-foreach="task_templates" t-as="template">
<div t-att-class="'panel %s' % ('panel-warning' if not template.super_coop_id else 'panel-default',)">
<div class="visible-xs" t-foreach="task_tpls_data" t-as="template_data">
<t t-set="template" t-value="template_data[0]"/>
<t t-set="has_enough_workers" t-value="template_data[1]"/>
<t t-set="highlight_class" t-value="'panel-warning' if not has_enough_workers else 'panel-default'"/>
<div t-att-class="'panel %s' % highlight_class">
<div class="panel-heading clearfix">
<div class="panel-title pull-left">
<t t-esc="template.planning_id.name"/> :
@ -104,9 +107,11 @@
</tr>
</thead>
<tbody>
<t t-foreach="task_templates" t-as="template">
<t t-foreach="task_tpls_data" t-as="template_data">
<t t-set="template" t-value="template_data[0]"/>
<t t-set="has_enough_workers" t-value="template_data[1]"/>
<!-- Row with no super coop will be shown in color -->
<tr t-attf-class="{{ 'warning' if not template.super_coop_id else '' }}">
<tr t-attf-class="{{ 'warning' if not has_enough_workers else '' }}">
<td>
<t t-esc="template.planning_id.name"/>
</td>

Loading…
Cancel
Save