[IMP] website_hr
bzr revid: chm@openerp.com-20130802035434-zynhb3ogkozn8ak1
This commit is contained in:
parent
cb67d10b5c
commit
de0e2ab313
|
@ -11,6 +11,8 @@ OpenERP Blog
|
|||
'depends': ['website', 'hr'],
|
||||
'data': [
|
||||
'views/website_hr.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'security/website_hr.xml',
|
||||
],
|
||||
'qweb': ['static/src/xml/*.xml'],
|
||||
'installable': True,
|
||||
|
|
|
@ -6,7 +6,7 @@ from openerp.addons.website import website
|
|||
|
||||
class website_hr(http.Controller):
|
||||
|
||||
@http.route(['/team'], type='http', auth="public")
|
||||
@http.route(['/hr'], type='http', auth="public")
|
||||
def blog(self, **post):
|
||||
hr_obj = request.registry['hr.employee']
|
||||
|
||||
|
@ -15,5 +15,27 @@ class website_hr(http.Controller):
|
|||
'employee_ids': hr_obj.browse(request.cr, request.uid, employee_ids),
|
||||
}
|
||||
|
||||
html = website.render(request.cr, request.uid, "website_hr.index", values)
|
||||
html = website.render("website_hr.index", values)
|
||||
return html
|
||||
|
||||
@http.route(['/hr/publish'], type='http', auth="public")
|
||||
def publish(self, **post):
|
||||
obj_id = int(post['id'])
|
||||
data_obj = request.registry['hr.employee']
|
||||
|
||||
obj = data_obj.browse(request.cr, request.uid, obj_id)
|
||||
data_obj.write(request.cr, request.uid, [obj_id], {'website_published': not obj.website_published})
|
||||
obj = data_obj.browse(request.cr, request.uid, obj_id)
|
||||
|
||||
return obj.website_published and "1" or "0"
|
||||
|
||||
@http.route(['/hr/publish_contact'], type='http', auth="public")
|
||||
def publish_contact(self, **post):
|
||||
obj_id = int(post['id'])
|
||||
data_obj = request.registry['hr.employee']
|
||||
|
||||
obj = data_obj.browse(request.cr, request.uid, obj_id)
|
||||
data_obj.write(request.cr, request.uid, [obj_id], {'website_published_on_contact_form': not obj.website_published_on_contact_form})
|
||||
obj = data_obj.browse(request.cr, request.uid, obj_id)
|
||||
|
||||
return obj.website_published_on_contact_form and "1" or "0"
|
||||
|
|
|
@ -6,6 +6,7 @@ from openerp.osv import osv, fields
|
|||
class hr(osv.osv):
|
||||
_inherit = 'hr.employee'
|
||||
_columns = {
|
||||
'website_important': fields.boolean('Publish', help="Publish also on contact form"),
|
||||
'website_published': fields.boolean('Available in the website'),
|
||||
'website_published_on_contact_form': fields.boolean('Publish', help="Publish also on contact form"),
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_hr_employee_public,hr.employee.public,hr.model_hr_employee,base.group_public,1,0,0,0
|
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="hr_employee_public" model="ir.rule">
|
||||
<field name="name">hr_employee: Public</field>
|
||||
<field name="model_id" ref="hr.model_hr_employee"/>
|
||||
<field name="domain_force">['|', ('visibility', '=', 'public'), ("website_published_on_contact_form", "=", True)]</field>
|
||||
<field name="groups" eval="[(4, ref('base.group_public'))]"/>
|
||||
<field name="perm_read" eval="True"/>
|
||||
<field name="perm_write" eval="False"/>
|
||||
<field name="perm_create" eval="False"/>
|
||||
<field name="perm_unlink" eval="False"/>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
|
@ -1,3 +1,34 @@
|
|||
$(document).ready(function () {
|
||||
|
||||
$(document).on('click', '.js_publish, .js_unpublish', function (e) {
|
||||
e.preventDefault();
|
||||
var $link = $(this).parent();
|
||||
$link.find('.js_publish, .js_unpublish').addClass("hidden");
|
||||
var $unp = $link.find(".js_unpublish");
|
||||
var $p = $link.find(".js_publish");
|
||||
$.post('/hr/publish', {'id': $link.data('id')}, function (result) {
|
||||
if (+result) {
|
||||
$p.addClass("hidden");
|
||||
$unp.removeClass("hidden");
|
||||
} else {
|
||||
$p.removeClass("hidden");
|
||||
$unp.addClass("hidden");
|
||||
}
|
||||
});
|
||||
});
|
||||
$(document).on('click', '.js_publish_contact, .js_unpublish_contact', function (e) {
|
||||
e.preventDefault();
|
||||
var $link = $(this).parent();
|
||||
$link.find('.js_publish_contact, .js_unpublish_contact').addClass("hidden");
|
||||
var $unp = $link.find(".js_unpublish_contact");
|
||||
var $p = $link.find(".js_publish_contact");
|
||||
$.post('/hr/publish_contact', {'id': $link.data('id')}, function (result) {
|
||||
if (+result) {
|
||||
$p.addClass("hidden");
|
||||
$unp.removeClass("hidden");
|
||||
} else {
|
||||
$p.removeClass("hidden");
|
||||
$unp.addClass("hidden");
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
|
@ -10,7 +10,7 @@
|
|||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="//a[@href='/page/website.contactus']" position="after">
|
||||
<li><a href="/team">Team</a></li>
|
||||
<li><a href="/hr">Team</a></li>
|
||||
</xpath>
|
||||
</data>
|
||||
</field>
|
||||
|
@ -21,27 +21,42 @@
|
|||
<template id="index">
|
||||
<t t-call="website.layout">
|
||||
<t t-set="head">
|
||||
<script type="text/javascript" src="/website_mail/static/src/js/blog.js"></script>
|
||||
<link rel='stylesheet' href='/website_mail/static/src/css/blog.css'/>
|
||||
<script type="text/javascript" src="/website_hr/static/src/js/hr.js"></script>
|
||||
<t t-raw="head"/>
|
||||
</t>
|
||||
<t t-set="title">Team</t>
|
||||
<div class="container mt48">
|
||||
<ul class="media-list">
|
||||
<t t-foreach="employee_ids">
|
||||
<!-- TODO: check qweb iteration -->
|
||||
<li class="media pull-left">
|
||||
<div t-att-class="'media-body %%s' %% (website_important and 'css_important' or '')">
|
||||
<a href="#" t-att-data-id="id" class="js_important pull-right" groups="group_website_mail_manager">
|
||||
<span class="label label-success">Unpublish</span>
|
||||
<span class="label label-important">Publish</span>
|
||||
<div class="container">
|
||||
<div class="thumbnails">
|
||||
<t t-foreach="employee_ids" t-as="employee_id">
|
||||
<div class="span4 mt16">
|
||||
<div class="media thumbnail">
|
||||
<a class="pull-left" href="#">
|
||||
<img class="media-object" t-att-src="'data:image/png;base64,%%s' %% employee_id.image_small"/>
|
||||
</a>
|
||||
<t t-raw="image"/>
|
||||
<t t-raw="name"/>
|
||||
<div class="media-body">
|
||||
<t t-if="editable">
|
||||
<div class="pull-right">
|
||||
<a href="#" t-att-data-id="employee_id.id">
|
||||
<span t-att-class="'label label-success js_unpublish %%s' %% (not employee_id.website_published and 'hidden' or '')">Click to Unpublish</span>
|
||||
<span t-att-class="'label label-important js_publish %%s' %% (employee_id.website_published and 'hidden' or '')">Click to Publish</span>
|
||||
</a><br/>
|
||||
<a href="#" t-att-data-id="employee_id.id">
|
||||
<span t-att-class="'label label-success js_unpublish_contact %%s' %% (not employee_id.website_published and 'hidden' or '')">hidden on Contacts</span>
|
||||
<span t-att-class="'label label-important js_publish_contact %%s' %% (employee_id.website_published and 'hidden' or '')">display in Contacts</span>
|
||||
</a>
|
||||
</div>
|
||||
</t>
|
||||
<h5 class="media-heading"><t t-esc="employee_id.name"/></h5>
|
||||
<div t-record="employee_id" t-field="department_id"> </div>
|
||||
<div t-record="employee_id" t-field="job_id"> </div>
|
||||
<div t-record="employee_id" t-field="work_location"> </div>
|
||||
<div t-record="employee_id" t-field="work_phone"> </div>
|
||||
<div t-record="employee_id" t-field="work_email"> </div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</div>
|
||||
</t>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
</template>
|
||||
|
|
Loading…
Reference in New Issue