[IMP][REF] website_hr: add of published mixin, update of displayed

employees. Website publishers now see all employees + a publish button, like
for other website documents. Other people see the same published employees
as before.

The URL link for employees is not a specific url for each employee but the
about us page.
This commit is contained in:
David Monjoie
2015-01-20 17:34:33 +01:00
committed by Thibault Delavallée
parent 280774ae8d
commit b81d384c52
5 changed files with 40 additions and 11 deletions
+1
View File
@@ -16,6 +16,7 @@ Our Team Page
'data': [
'data/website_hr_data.xml',
'views/website_hr.xml',
'views/website_hr_view.xml',
'security/ir.model.access.csv',
'security/website_hr.xml',
],
+5 -3
View File
@@ -8,10 +8,12 @@ class website_hr(http.Controller):
@http.route(['/page/website.aboutus', '/page/aboutus'], type='http', auth="public", website=True)
def blog(self, **post):
hr_obj = request.registry['hr.employee']
employee_ids = hr_obj.search(request.cr, request.uid, [('website_published', '=', True)],
context=request.context)
if request.registry['res.users'].has_group(request.cr, request.uid, 'base.group_website_publisher'):
employee_ids = hr_obj.search(request.cr, request.uid, [], context=request.context)
else:
employee_ids = hr_obj.search(request.cr, request.uid, [('website_published', '=', True)], context=request.context)
values = {
'employee_ids': hr_obj.browse(request.cr, request.uid, employee_ids,
request.context)
request.context),
}
return request.website.render("website.aboutus", values)
+9 -6
View File
@@ -3,12 +3,15 @@
from openerp.osv import osv, fields
class hr(osv.osv):
_inherit = 'hr.employee'
class hr_employee(osv.osv):
_name = 'hr.employee'
_inherit = ['hr.employee', 'website.published.mixin']
_columns = {
'website_published': fields.boolean('Available in the website', copy=False),
'public_info': fields.text('Public Info'),
}
_defaults = {
'website_published': False
}
def _website_url(self, cr, uid, ids, field_name, arg, context=None):
res = super(hr_employee, self)._website_url(cr, uid, ids, field_name, arg, context=context)
res.update({(employee_id, '/page/website.aboutus#team') for employee_id in ids})
return res
+5 -2
View File
@@ -5,12 +5,15 @@
<template id="aboutus" inherit_id="website.aboutus" customize_show="True" name="Our Team">
<xpath expr="//div[@class='oe_structure']" position="after">
<section class="container">
<section class="container" id="team">
<div class="col-sm-12 text-center" t-if="len(employee_ids)">
<h2>Our Team</h2>
</div>
<div t-foreach="employee_ids" t-as="employee" class="col-sm-3 col-lg-2 mt16 text-center colsize">
<t t-call="website.publish_management"><t t-set="object" t-value="employee"/></t>
<t t-call="website.publish_management">
<t t-set="object" t-value="employee"/>
<t t-set="publish_edit" t-value="True"/>
</t>
<div class="clearfix"/>
<img t-att-src="website.image_url(employee, 'image_medium')" class="img shadow img-rounded"/>
<div class="mt8">
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model="ir.ui.view" id="hr_employee_form_view_website_published">
<field name="name">hr.employee.website.form</field>
<field name="model">hr.employee</field>
<field name="inherit_id" ref="hr.view_employee_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@name='button_box']" position="inside">
<button class="oe_inline oe_stat_button" name="open_website_url"
type="object" icon="fa-globe">
<field name="website_published" widget="website_button"/>
</button>
</xpath>
</field>
</record>
</data>
</openerp>