Browse Source

[ADD] b_website_shift: shift status

Show the shift status in the list of the next shifts of a worker. For
small screen shift status is represented by a colored label.

Add shift status as a label for the past shift of a worker on small screen.
pull/55/head
Rémy Taymans 6 years ago
parent
commit
55ba363e53
  1. 5
      beesdoo_website_shift/controllers/main.py
  2. 50
      beesdoo_website_shift/views/my_shift_website_templates.xml

5
beesdoo_website_shift/controllers/main.py

@ -334,6 +334,9 @@ class WebsiteShiftController(http.Controller):
regular_next_shift_limit = int(request.env['ir.config_parameter'].get_param(
'beesdoo_website_shift.regular_next_shift_limit'))
# Get default status for fictive shifts
draft_status = request.env.ref('beesdoo_shift.draft')
for i in range(nb_subscribed_shifts, regular_next_shift_limit):
# Create the fictive shift
shift = main_shift.new()
@ -342,7 +345,7 @@ class WebsiteShiftController(http.Controller):
shift.planning_id = main_shift.planning_id
shift.task_type_id = main_shift.task_type_id
shift.worker_id = main_shift.worker_id
shift.stage_id = main_shift.stage_id
shift.stage_id = draft_status
shift.super_coop_id = main_shift.super_coop_id
shift.color = main_shift.color
shift.is_regular = main_shift.is_regular

50
beesdoo_website_shift/views/my_shift_website_templates.xml

@ -96,6 +96,44 @@
</template>
<template
id="shift_status_label"
name="Shift Status Label">
<span t-if="shift.stage_id.code == 'draft'"
t-attf-class="label label-default {{label_css}}">
<t t-esc="shift.stage_id.name"/>
</span>
<span t-if="shift.stage_id.code == 'done'"
t-attf-class="label label-success {{label_css}}">
<t t-esc="shift.stage_id.name"/>
</span>
<span t-if="shift.stage_id.code == 'absent'"
t-attf-class="label label-warning {{label_css}}">
<t t-esc="shift.stage_id.name"/>
</span>
<span t-if="shift.stage_id.code == 'excused'"
t-attf-class="label label-info {{label_css}}">
<t t-esc="shift.stage_id.name"/>
</span>
<span t-if="shift.stage_id.code == 'excused_necessity'"
t-attf-class="label label-info {{label_css}}">
<t t-esc="shift.stage_id.name"/>
</span>
<span t-if="shift.stage_id.code == 'cancel'"
t-attf-class="label label-danger {{label_css}}">
<t t-esc="shift.stage_id.name"/>
</span>
</template>
<template
id="my_shift_next_shifts"
name="My Shift : Next Shifts">
@ -138,6 +176,9 @@
<t t-esc="time.strftime('%A %d %B %Y', time.strptime(shift.start_time, '%Y-%m-%d %H:%M:%S'))"/>
<span t-field="shift.start_time" t-field-options='{"format": "HH:mm"}'/> -
<span t-field="shift.end_time" t-field-options='{"format": "HH:mm"}'/>
<t t-call="beesdoo_website_shift.shift_status_label">
<t t-set="label_css" t-value="'pull-right'"/>
</t>
</div>
</div>
<div class="panel-body">
@ -160,12 +201,13 @@
<th>Date</th>
<th>Time</th>
<th>Type of Shift</th>
<th>Status</th>
<th class="text-center">Super Cooperator Info</th>
</tr>
</thead>
<tbody>
<t t-foreach="subscribed_shifts" t-as="shift">
<tr>
<tr t-att-class="'danger text-danger' if shift.stage_id.code == 'cancel' else ''">
<td>
<t t-esc="time.strftime('%A', time.strptime(shift.start_time, '%Y-%m-%d %H:%M:%S'))"/>
</td>
@ -179,6 +221,9 @@
<td>
<t t-esc="shift.task_type_id.name"/>
</td>
<td>
<t t-esc="shift.stage_id.name"/>
</td>
<td class="text-center">
<button type="button" class="btn btn-default btn-sm"
t-if="shift.super_coop_id.name"
@ -264,6 +309,9 @@
<t t-esc="time.strftime('%A %d %B %Y', time.strptime(shift.start_time, '%Y-%m-%d %H:%M:%S'))"/>
<span t-field="shift.start_time" t-field-options='{"format": "HH:mm"}'/> -
<span t-field="shift.end_time" t-field-options='{"format": "HH:mm"}'/>
<t t-call="beesdoo_website_shift.shift_status_label">
<t t-set="label_css" t-value="'pull-right'"/>
</t>
</div>
</div>
<div class="panel-body">

Loading…
Cancel
Save