Browse Source

[FIX] beesdoo_portal_shift: change name

Change name from beesdoo_portal_shift to beesdoo_website_shift.
pull/128/head
Rémy Taymans 7 years ago
parent
commit
72c6e2128d
  1. 1
      beesdoo_website_shift/__init__.py
  2. 24
      beesdoo_website_shift/__openerp__.py
  3. 1
      beesdoo_website_shift/controllers/__init__.py
  4. 41
      beesdoo_website_shift/controllers/main.py
  5. 17
      beesdoo_website_shift/data/config_data.xml
  6. 122
      beesdoo_website_shift/i18n/fr_BE.po
  7. 3
      beesdoo_website_shift/static/src/css/design.css
  8. 125
      beesdoo_website_shift/views/shift_website_templates.xml

1
beesdoo_website_shift/__init__.py

@ -0,0 +1 @@
from . import controllers

24
beesdoo_website_shift/__openerp__.py

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
{
'name': 'Beescoop Shift Website',
'summary': """
Show available shifts for regular and irregular workers in
portal.
""",
'description': """
""",
'author': 'Rémy Taymans',
'website': "https://github.com/beescoop/Obeesdoo",
'category': 'Cooperative management',
'version': '0.1',
'depends': ['website', 'beesdoo_shift'],
'data': [
'views/shift_website_templates.xml',
'data/config_data.xml',
]
}

1
beesdoo_website_shift/controllers/__init__.py

@ -0,0 +1 @@
from . import main

41
beesdoo_website_shift/controllers/main.py

@ -0,0 +1,41 @@
# -*- coding: utf8 -*-
from datetime import datetime
from itertools import groupby
from openerp import http
from openerp.http import request
from openerp.addons.beesdoo_shift.models.planning import float_to_time
class ShiftPortalController(http.Controller):
@http.route('/shift_irregular_worker', auth='public', website=True)
def shift_irregular_worker(self, **kwargs):
# Get all the shifts in the future with no worker
now = datetime.now()
shifts = request.env['beesdoo.shift.shift'].sudo().search(
[('start_time', '>', now.strftime("%Y-%m-%d %H:%M:%S")),
('worker_id', '=', False)],
order="start_time, task_template_id, task_type_id",
)
shifts_and_count = []
for _, val in groupby(shifts, lambda s: s.task_template_id):
s = [v for v in val]
shifts_and_count.append([len(s), s[0]])
return request.render('beesdoo_website_shift.shift_template',
{'shift_templates': shifts_and_count}
)
@http.route('/shift_template_regular_worker', auth='public', website=True)
def shift_template_regular_worker(self, **kwargs):
# 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',
{
'task_templates': task_templates,
'float_to_time': float_to_time
}
)

17
beesdoo_website_shift/data/config_data.xml

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<record id="menu_work_irregular" model="website.menu">
<field name="name">Shifts Irregular</field>
<field name="url">/shift_irregular_worker</field>
<field name="parent_id" ref="website.main_menu"/>
<field name="sequence" type="int">50</field>
</record>
<record id="menu_work_regular" model="website.menu">
<field name="name">Shifts Regular</field>
<field name="url">/shift_template_regular_worker</field>
<field name="parent_id" ref="website.main_menu"/>
<field name="sequence" type="int">51</field>
</record>
</data>
</openerp>

122
beesdoo_website_shift/i18n/fr_BE.po

@ -0,0 +1,122 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * beesdoo_portal_shift
#
# Tanslators:
# Rémy Taymans <remytaymans@gmail.com>, 2017
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 9.0c\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-09-29 09:02+0000\n"
"PO-Revision-Date: 2017-09-29 11:08+0200\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n"
"Language: fr_BE\n"
"X-Generator: Poedit 1.8.11\n"
#. module: beesdoo_portal_shift
#: model:ir.ui.view,arch_db:beesdoo_portal_shift.task_template
msgid "Available Tasks Templates for Regular Workers"
msgstr "Créneaux disponibles pour les travailleurs réguliers"
#. module: beesdoo_portal_shift
#: model:ir.ui.view,arch_db:beesdoo_portal_shift.shift_template
msgid "Available Shifts for Irregular Workers"
msgstr "Shifts disponibles pour les travailleurs volants"
#. module: beesdoo_portal_shift
#: model:ir.ui.view,arch_db:beesdoo_portal_shift.shift_template
msgid "Date"
msgstr "Date"
#. module: beesdoo_portal_shift
#: model:ir.ui.view,arch_db:beesdoo_portal_shift.shift_template
msgid "Day"
msgstr "Jour"
#. module: beesdoo_portal_shift
#: model:ir.ui.view,arch_db:beesdoo_portal_shift.shift_template
#: model:ir.ui.view,arch_db:beesdoo_portal_shift.task_template
msgid "Available Spaces"
msgstr "Places disponibles"
#. module: beesdoo_portal_shift
#: model:ir.ui.view,arch_db:beesdoo_portal_shift.task_template
msgid "Subscribe via the member office or via"
msgstr "Inscription au bureau des membres ou via"
#. module: beesdoo_portal_shift
#: model:ir.ui.view,arch_db:beesdoo_portal_shift.shift_template
msgid "Subscribe via"
msgstr "Inscription via"
#. module: beesdoo_portal_shift
#: model:ir.ui.view,arch_db:beesdoo_portal_shift.task_template
msgid "Not yet"
msgstr "Pas encore"
#. module: beesdoo_portal_shift
#: model:ir.ui.view,arch_db:beesdoo_portal_shift.shift_template
msgid "Shift"
msgstr "Shift"
#. module: beesdoo_portal_shift
#: model:website.menu,name:beesdoo_portal_shift.menu_work_irregular
msgid "Shifts Irregular"
msgstr "Shifts"
#. module: beesdoo_portal_shift
#: model:website.menu,name:beesdoo_portal_shift.menu_work_regular
msgid "Shifts Regular"
msgstr "Créneaux"
#. module: beesdoo_portal_shift
#: model:ir.ui.view,arch_db:beesdoo_portal_shift.task_template
msgid "Super Co-operator"
msgstr "Super-coopérateur"
#. module: beesdoo_portal_shift
#: model:ir.ui.view,arch_db:beesdoo_portal_shift.task_template
msgid "Task Template"
msgstr "Créneau"
#. module: beesdoo_portal_shift
#: model:ir.ui.view,arch_db:beesdoo_portal_shift.shift_template
#: model:ir.ui.view,arch_db:beesdoo_portal_shift.task_template
msgid "Time"
msgstr "Heures"
#. module: beesdoo_portal_shift
#: model:ir.ui.view,arch_db:beesdoo_portal_shift.shift_template
msgid "Type of Shift"
msgstr "Type de shift"
#. module: beesdoo_portal_shift
#: model:ir.ui.view,arch_db:beesdoo_portal_shift.task_template
msgid "Type of Task"
msgstr "Type de créneau"
#. module: beesdoo_portal_shift
#: model:ir.ui.view,arch_db:beesdoo_portal_shift.task_template
msgid "Week"
msgstr "Semaine"
#. module: beesdoo_portal_shift
#: model:ir.ui.view,arch_db:beesdoo_portal_shift.task_template
msgid "Yes"
msgstr "Oui"
#. module: beesdoo_portal_shift
#: model:ir.ui.view,arch_db:beesdoo_portal_shift.task_template
msgid "membre@bees-coop.be"
msgstr "membre@bees-coop.be"
#. module: beesdoo_portal_shift
#: model:ir.ui.view,arch_db:beesdoo_portal_shift.shift_template
msgid "volant@bees-coop.be"
msgstr "volant@bees-coop.be"

3
beesdoo_website_shift/static/src/css/design.css

@ -0,0 +1,3 @@
h1 {
color: grey;
}

125
beesdoo_website_shift/views/shift_website_templates.xml

@ -0,0 +1,125 @@
<openerp>
<!-- We add the css stylesheet -->
<template id="assets_frontend" name="beesdoo_website_shift_website_assets"
inherit_id="website.assets_frontend">
<xpath expr="." position="inside">
<link rel="stylesheet" type="text/css"
href="/beesdoo_website_shift/static/src/css/design.css"/>
</xpath>
</template>
<!-- Task template page -->
<template id="task_template" name="Task template for regular worker">
<t t-call="website.layout">
<div class="container">
<h1>Available Tasks Templates for Regular Workers</h1>
<p class="text-center">
Subscribe via the member office or via <a href="mailto:membre@bees-coop.be">membre@bees-coop.be</a>
</p>
<table class="table table-striped">
<thead>
<tr>
<th>Week</th>
<th>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>
<t t-esc="template.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>
</t>
</template>
<!-- Shift page -->
<template id="shift_template" name="Shift for irregular worker">
<t t-call="website.layout">
<div class="container">
<h1>Available Shifts for Irregular Workers</h1>
<p class="text-center">
Subscribe via <a href="mailto:volant@bees-coop.be">volant@bees-coop.be</a>
</p>
<table class="table table-striped">
<thead>
<tr>
<th>Day</th>
<th>Date</th>
<th>Time</th>
<th>Shift</th>
<th>Type of Shift</th>
<th class="text-center">Available Spaces</th>
</tr>
</thead>
<tbody>
<t t-foreach="shift_templates" t-as="shift_and_count">
<t t-set="count" t-value="shift_and_count[0]" />
<t t-set="shift" t-value="shift_and_count[1]" />
<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_template_id.name"/>
</td>
<td>
<t t-esc="shift.task_type_id.name"/>
</td>
<td class="text-center">
<t t-esc="count"/>
</td>
</tr>
</t>
</tbody>
</table>
</div>
</t>
</template>
</openerp>
Loading…
Cancel
Save