Browse Source

[ADD] website_shift: Regular personal work page

Add personal shift page for regular worker.
pull/33/head
Rémy Taymans 7 years ago
parent
commit
8df3adbfc3
  1. 20
      beesdoo_website_shift/controllers/main.py
  2. 303
      beesdoo_website_shift/views/shift_website_templates.xml

20
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,
}
)

303
beesdoo_website_shift/views/shift_website_templates.xml

@ -49,10 +49,10 @@
</t>
</template>
<!-- Available Tasks Templates for Regular Workers -->
<!-- Shifts for Regular Workers -->
<template
id="task_template"
name="Available Tasks Templates for Regular Workers"
id="regular_worker"
name="Shifts for Regular Workers"
page="True">
<t t-call="website.layout">
@ -63,7 +63,7 @@
<div class="row">
<div class="col-md-12">
<h1 class="text-center">
Available Tasks Templates for Regular Workers
Your shifts
</h1>
</div>
</div>
@ -75,102 +75,229 @@
<section class="wrap">
<div class="container">
<div class="row">
<div class="col-md-12">
<p class="text-center">
Subscribe via the member office or via
<a href="mailto:membre@bees-coop.be">membre@bees-coop.be</a>
<div class="col-xs-12 col-md-4 pull-right">
<section class="wrap">
<div class="container">
<div class="row">
<div class="col-md-12">
<h2>
Worker status
</h2>
</div>
</div>
</div>
</section>
<div class="oe_structure"/>
<p>
<label>Working Mode:</label>
<t t-esc="dict(status.fields_get(allfields=['working_mode'])['working_mode']['selection'])[status.working_mode]"/>
</p>
<p>
<label>Status:</label>
<t t-esc="dict(status.fields_get(allfields=['status'])['status']['selection'])[status.status]"/>
</p>
<p>
<label>Regular Shift Counter:</label>
<t t-esc="status.sr"/>
</p>
<p>
<label>Compensation Shift Counter:</label>
<t t-esc="status.sc"/>
</p>
<t t-if="status.holiday_start_time">
<p>
<label>Holiday start time:</label>
<t t-esc="status.holiday_start_time"/>
</p>
<p>
<label>Holiday end time:</label>
<t t-esc="status.holiday_end_time"/>
</p>
</t>
<p>
<label>Alert start date:</label>
<t t-esc="status.alert_start_time"/>
</p>
<p>
<label>Extension start date:</label>
<t t-esc="status.extension_start_time"/>
</p>
<div class="oe_structure"/>
</div>
</div>
</div>
</section>
<div class="oe_structure"/>
<div class="col-xs-12 col-md-8">
<section class="wrap">
<div class="container">
<div class="row">
<section class="wrap">
<div class="container">
<div class="row">
<div class="col-md-12">
<h2>
Your next shifts
</h2>
</div>
</div>
</div>
</section>
<p class="visible-xs text-center">
<span class="label label-warning">NSC</span> : This flag tells you that the shift needs a Super Co-operator
</p>
<div class="visible-xs" t-foreach="task_templates" t-as="template">
<ul class="list-group">
<li class="list-group-item">
<t t-esc="template.planning_id.name"/> :
<t t-esc="template.day_nb_id.name"/>
<t t-esc='float_to_time(template.start_time)' /> -
<t t-esc='float_to_time(template.end_time)'/>
<span class="label label-warning pull-right"
t-if="not template.super_coop_id">
NSC
</span>
</li>
<li class="list-group-item">
<t t-esc="template.task_type_id.name"/>
<span class="badge"
t-if="template.remaining_worker > 0">
<t t-esc="template.remaining_worker"/> space(s)
</span>
<span class="badge"
t-if="template.remaining_worker == 0">
full
</span>
</li>
</ul>
</div>
<div class="oe_structure"/>
<div class="visible-xs" t-foreach="subscribed_shifts" t-as="shift">
<div class="panel panel-default">
<div class="panel-heading clearfix">
<div class="panel-title">
<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"}'/>
</div>
</div>
<div class="panel-body">
<t t-esc="shift.task_type_id.name"/>
</div>
</div>
</div>
<table class="hidden-xs table table-striped">
<thead>
<tr>
<th>Day</th>
<th>Date</th>
<th>Time</th>
<th>Type of Shift</th>
</tr>
</thead>
<tbody>
<t t-foreach="subscribed_shifts" t-as="shift">
<tr>
<td>
<t t-esc="time.strftime('%A', time.strptime(shift.start_time, '%Y-%m-%d %H:%M:%S'))"/>
</td>
<td>
<t t-esc="time.strftime('%d %B %Y', time.strptime(shift.start_time, '%Y-%m-%d %H:%M:%S'))"/>
</td>
<td>
<span t-field="shift.start_time" t-field-options='{"format": "HH:mm"}'/> -
<span t-field="shift.end_time" t-field-options='{"format": "HH:mm"}'/>
</td>
<td>
<t t-esc="shift.task_type_id.name"/>
</td>
</tr>
</t>
</tbody>
</table>
<table class="hidden-xs table table-striped">
<thead>
<tr>
<th>Week</th>
<th class="hidden-sm">Task Template</th>
<th>Day</th>
<th>Time</th>
<th>Type of Task</th>
<th>Super Co-operator</th>
<th class="text-center">Available Spaces</th>
</tr>
</thead>
<tbody>
<t t-foreach="task_templates" t-as="template">
<!-- Row with no super coop will be shown in color -->
<tr t-attf-class="{{ 'warning' if not template.super_coop_id else '' }}">
<td>
<t t-esc="template.planning_id.name"/>
</td>
<td class="hidden-sm">
<t t-esc="template.name"/>
</td>
<td>
<section class="wrap">
<div class="container">
<div class="row">
<div class="col-md-12">
<h2>
Available Task Templates
</h2>
</div>
</div>
</div>
</section>
<div class="oe_structure"/>
<section class="wrap">
<div class="container">
<div class="row">
<div class="col-md-12">
<p class="text-center">
Explanation text
</p>
</div>
</div>
</div>
</section>
<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="panel-heading clearfix">
<div class="panel-title pull-left">
<t t-esc="template.planning_id.name"/> :
<t t-esc="template.day_nb_id.name"/>
</td>
<td>
<t t-esc='float_to_time(template.start_time)' /> -
<t t-esc='float_to_time(template.end_time)'/>
</td>
<td>
<t t-esc="template.task_type_id.name"/>
</td>
<td>
<t t-if="template.super_coop_id">
Yes
</t>
<t t-if="not template.super_coop_id">
Not yet
</t>
</td>
<td class="text-center">
<t t-esc="template.remaining_worker"/>
</td>
</div>
<div class="label label-default pull-right"
t-if="template.remaining_worker > 0">
<t t-esc="template.remaining_worker"/> space(s)
</div>
<div class="label label-default pull-right"
t-if="template.remaining_worker == 0">
full
</div>
</div>
<div class="panel-body clearfix">
<t t-esc="template.task_type_id.name"/>
<div class="label label-warning pull-right"
t-if="not template.super_coop_id">
Need Super Co-operator
</div>
</div>
</div>
</div>
<table class="hidden-xs table table-striped">
<thead>
<tr>
<th>Week</th>
<th>Day</th>
<th>Time</th>
<th>Type of Task</th>
<th>Super Co-operator</th>
<th class="text-center">Available Spaces</th>
</tr>
</t>
</tbody>
</table>
</div>
</div>
</thead>
<tbody>
<t t-foreach="task_templates" t-as="template">
<!-- Row with no super coop will be shown in color -->
<tr t-attf-class="{{ 'warning' if not template.super_coop_id else '' }}">
<td>
<t t-esc="template.planning_id.name"/>
</td>
<td>
<t t-esc="template.day_nb_id.name"/>
</td>
<td>
<t t-esc='float_to_time(template.start_time)' /> -
<t t-esc='float_to_time(template.end_time)'/>
</td>
<td>
<t t-esc="template.task_type_id.name"/>
</td>
<td>
<t t-if="template.super_coop_id">
Yes
</t>
<t t-if="not template.super_coop_id">
Not yet
</t>
</td>
<td class="text-center">
<t t-esc="template.remaining_worker"/>
</td>
</tr>
</t>
</tbody>
</table>
</div> <!-- col-md-8 -->
</div> <!-- row -->
</div> <!-- container -->
</section>
<div class="oe_structure"/>
</t>
</template>

Loading…
Cancel
Save