[IMP]Improved code for publish/unpublish.
bzr revid: bth@tinyerp.com-20130819130500-1phrr1uuhlpmlx77
This commit is contained in:
parent
91bd07ae3d
commit
e051b6269a
|
@ -13,9 +13,6 @@ OpenERP Contact Form
|
|||
'views/website_hr_recruitment.xml',
|
||||
'security/website_hr_recruitment_security.xml',
|
||||
],
|
||||
'js':[
|
||||
'static/src/js/*.js',
|
||||
],
|
||||
'css':[
|
||||
'static/src/css/*.css'
|
||||
],
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
from openerp.addons.web import http
|
||||
from openerp.addons.web.http import request
|
||||
import base64
|
||||
import simplejson
|
||||
|
||||
from urllib import quote_plus
|
||||
|
||||
|
@ -16,7 +17,7 @@ class website_hr_recruitment(http.Controller):
|
|||
|
||||
domain = [(1, '=', 1)] or [('website_published', '=', True)]
|
||||
search = [("state", 'in', ['recruit', 'open'])]
|
||||
domain += search
|
||||
domain += search
|
||||
|
||||
jobpost_ids = hr_job_obj.search(request.cr, request.uid, domain)
|
||||
request.cr.execute("select distinct(com.id) from hr_job job, res_company com where com.id=job.company_id")
|
||||
|
@ -24,9 +25,13 @@ class website_hr_recruitment(http.Controller):
|
|||
for i in request.cr.fetchall():
|
||||
ids.append(i[0])
|
||||
companies = request.registry['res.company'].browse(request.cr, request.uid, ids)
|
||||
vals = {}
|
||||
for rec in hr_job_obj.browse(request.cr, request.uid, jobpost_ids):
|
||||
vals[rec.id] = {'count': int(rec.no_of_recruitment), 'date_recruitment': rec.write_date.split(' ')[0]}
|
||||
values = website.get_rendering_context({
|
||||
'companies': companies,
|
||||
'res_job': hr_job_obj.browse(request.cr, request.uid, jobpost_ids),
|
||||
'vals': vals,
|
||||
'subscribe': post.get('subscribe'),
|
||||
'job_id': None,
|
||||
'no_of_jobs': len(hr_job_obj.browse(request.cr, request.uid, jobpost_ids)),
|
||||
|
@ -104,4 +109,25 @@ class website_hr_recruitment(http.Controller):
|
|||
'jobid': post['job_id']
|
||||
})
|
||||
return website.render("website_hr_recruitment.thankyou", values)
|
||||
|
||||
@http.route(['/recruitment/published'], type='http', auth="admin")
|
||||
def published (self, **post):
|
||||
hr_job = request.registry['hr.job']
|
||||
id = int(post['id'])
|
||||
rec = hr_job.browse(request.cr, request.uid, id)
|
||||
vals = {}
|
||||
|
||||
vals['website_published'] = not rec.website_published
|
||||
if vals['website_published']:
|
||||
vals['state'] = 'recruit'
|
||||
if rec.no_of_recruitment == 0.0:
|
||||
vals ['no_of_recruitment'] = 1.0
|
||||
else:
|
||||
vals['state'] = 'open'
|
||||
vals ['no_of_recruitment'] = 0.0
|
||||
|
||||
res = hr_job.write(request.cr, request.uid, [rec.id], vals)
|
||||
obj = hr_job.browse(request.cr, request.uid, id)
|
||||
return obj.website_published and "1" or "0"
|
||||
|
||||
# vim:expandtab:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
|
||||
<template id="index" name="Jobs">
|
||||
<t t-call="website.layout">
|
||||
<t t-set="head">
|
||||
<script type="text/javascript" src="/website_hr_recruitment/static/src/js/recruitment.js"></script>
|
||||
<t t-raw="head or ''"/>
|
||||
</t>
|
||||
<t t-set="title">Jobs</t>
|
||||
<div class="container">
|
||||
<div class="page-header">
|
||||
|
@ -31,8 +35,12 @@
|
|||
<td>
|
||||
<a t-att-href="'/job/detail/%%s' %% job.id"><span class="lead" t-field="job.name"/></a><br/>
|
||||
<span t-if="job.department_id" t-esc="job.department_id.name"/><br/>
|
||||
<i class="icon-time"></i> <span t-field="job.write_date"/><br/>
|
||||
<span><t t-if="job.no_of_recruitment > 0"><i class="icon-group"></i> <t t-esc="job.no_of_recruitment"/></t>
|
||||
<i class="icon-time"></i> <t t-esc="vals[job.id]['date_recruitment']"/><br/>
|
||||
<span>
|
||||
<t t-if="job.no_of_recruitment > 0">
|
||||
<i class="icon-group"></i>
|
||||
No.of Post: <t t-esc="vals[job.id]['count']"></t>
|
||||
</t>
|
||||
<t t-if="job.no_of_recruitment < 1">Right now no recruitment is going on.</t>
|
||||
</span><br/>
|
||||
<span><i class="icon-map-marker"></i> <t t-field="res_company.city"/>
|
||||
|
@ -61,7 +69,7 @@
|
|||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<t t-call="website.publish"><t t-set="object" t-value="job"/></t>
|
||||
<t t-call="website_hr_recruitment.published"><t t-set="object" t-value="job"/></t>
|
||||
</td>
|
||||
</tr>
|
||||
</t>
|
||||
|
@ -75,6 +83,12 @@
|
|||
</div>
|
||||
</t>
|
||||
</template>
|
||||
<template id="published">
|
||||
<a href="#" t-att-data-id="object.id" t-att-data-object="object._name" class="pull-right" t-if="editable" t-ignore="true">
|
||||
<span t-att-class="'label label-success js_unpublished %%s' %% (not object.website_published and 'hidden' or '')">Unpublish</span>
|
||||
<span t-att-class="'label label-important js_published %%s' %% (object.website_published and 'hidden' or '')">Publish</span>
|
||||
</a>
|
||||
</template>
|
||||
<template id="detail">
|
||||
<t t-call="website.layout">
|
||||
<t t-set="title">Job Detail</t>
|
||||
|
|
Loading…
Reference in New Issue