[IMP]View is changed like event.

bzr revid: bth@tinyerp.com-20130920085839-o7jxsr7a9oa2h73o
This commit is contained in:
bth-openerp 2013-09-20 14:28:39 +05:30
parent 69efd997d6
commit 6a4d0f0270
3 changed files with 146 additions and 136 deletions

View File

@ -10,10 +10,12 @@ from urllib import quote_plus
class website_hr_recruitment(http.Controller):
@website.route(['/jobs', '/jobs/page/<int:page>/'], type='http', auth="public")
def jobs(self, page=1, **post):
@website.route(['/jobs', '/jobs/page/<int:page>/', '/department/<id>/', '/department/<id>/page/<int:page>/'], type='http', auth="public")
def jobs(self, id=0, page=1, **post):
id = id and int(id) or 0
website = request.registry['website']
hr_job_obj = request.registry['hr.job']
hr_department_obj = request.registry['hr.department']
domain = [(1, '=', 1)] or [('website_published', '=', True)]
search = [("state", 'in', ['recruit', 'open'])]
@ -31,21 +33,36 @@ class website_hr_recruitment(http.Controller):
step = 5
pager = request.website.pager(url="/jobs/", total=len(jobpost_ids), page=page, step=step, scope=5)
jobpost_ids = hr_job_obj.search(request.cr, request.uid, domain, limit=step, offset=pager['offset'])
department_ids = []
request.cr.execute("select * from hr_department")
for i in request.cr.fetchall():
department_ids.append(i[0])
if not id:
id = 1
active = id
jobids = hr_job_obj.search(request.cr, request.uid, [('department_id','=',id)])
step = 5
pager = request.website.pager(url="/jobs/", total=len(jobids), page=page, step=step, scope=5)
values = {
'active': active,
'companies': companies,
'res_job': hr_job_obj.browse(request.cr, request.uid, jobpost_ids),
'res_job': hr_job_obj.browse(request.cr, request.uid, jobids),
# 'res_job': hr_job_obj.browse(request.cr, request.uid, jobpost_ids),
'departments': hr_department_obj.browse(request.cr, request.uid, department_ids),
'vals': vals,
'no_of_jobs': len(hr_job_obj.browse(request.cr, request.uid, jobpost_ids)),
'pager': pager
}
return request.website.render("website_hr_recruitment.index", values)
@website.route(['/job/detail/<id>'], type='http', auth="public")
def detail(self, id=0):
id = id and int(id) or 0
website = request.registry['website']
values = {
'job': request.registry['hr.job'].browse(request.cr, request.uid, id)
'job': request.registry['hr.job'].browse(request.cr, request.uid, id),
'vals_date': request.registry['hr.job'].browse(request.cr, request.uid, id).write_date.split(' ')[0]
}
return request.website.render("website_hr_recruitment.detail", values)
@ -68,29 +85,52 @@ class website_hr_recruitment(http.Controller):
}
return request.website.render("website_hr_recruitment.thankyou", values)
@website.route('/recruitment/message_get_subscribed', type='json', auth="admin")
def message_get_subscribed(self, email, id, mail_group_id):
id = int(id)
mail_group_id = int(mail_group_id)
group_obj = request.registry['mail.group']
@website.route(['/job/detail/<int:job_id>/subscribe'], type='http', auth="public")
def subscribe(self, event_id=None, **post):
partner_obj = request.registry['res.partner']
partner_ids = partner_obj.search(request.cr, SUPERUSER_ID, [("email", "=", email)])
if not partner_ids:
partner_ids = [partner_obj.create(request.cr, SUPERUSER_ID, {"email": email, "name": "Subscribe: %s" % email})]
group_obj.check_access_rule(request.cr, request.uid, [mail_group_id], 'read')
group_obj.message_subscribe(request.cr, SUPERUSER_ID, [mail_group_id], partner_ids)
return 1
job_obj = request.registry['hr.job']
user_obj = request.registry['res.users']
@website.route('/recruitment/message_get_unsubscribed', type='json', auth="admin")
def message_get_unsubscribed(self, email, id, mail_group_id):
mail_group_id = int(mail_group_id)
id = int(id)
if job_id and 'subscribe' in post and (post.get('email') or not request.context['is_public_user']):
if request.context['is_public_user']:
partner_ids = partner_obj.search(
request.cr, SUPERUSER_ID, [("email", "=", post.get('email'))],
context=request.context)
if not partner_ids:
partner_data = {
"email": post.get('email'),
"name": "Subscribe: %s" % post.get('email')
}
partner_ids = [partner_obj.create(
request.cr, SUPERUSER_ID, partner_data, context=request.context)]
else:
partner_ids = [user_obj.browse(
request.cr, request.uid, request.uid,
context=request.context).partner_id.id]
job_obj.check_access_rule(request.cr, request.uid, [event_id],
'read', request.context)
job_obj.message_subscribe(request.cr, SUPERUSER_ID, [event_id],
partner_ids, request.context)
return self.detail(job_id=job_id)
@website.route(['/job/detail/<int:job_id>/unsubscribe'], type='http', auth="public")
def unsubscribe(self, job_id=None, **post):
partner_obj = request.registry['res.partner']
group_obj = request.registry['mail.group']
partner_ids = partner_obj.search(request.cr, SUPERUSER_ID, [("email", "=", email)])
group_obj.check_access_rule(request.cr, request.uid, [mail_group_id], 'read')
group_obj.message_unsubscribe(request.cr, SUPERUSER_ID, [mail_group_id], partner_ids)
return 1
job_obj = request.registry['hr.job']
user_obj = request.registry['res.users']
if job_id and 'unsubscribe' in post and (post.get('email') or not request.context['is_public_user']):
if request.context['is_public_user']:
partner_ids = partner_obj.search(
request.cr, SUPERUSER_ID, [("email", "=", post.get('email'))],
context=request.context)
else:
partner_ids = [user_obj.browse(request.cr, request.uid, request.uid, request.context).partner_id.id]
job_obj.check_access_rule(request.cr, request.uid, [event_id], 'read', request.context)
job_obj.message_unsubscribe(request.cr, SUPERUSER_ID, [job_id], partner_ids, request.context)
return self.detail(job_id=job_id)
@website.route('/recruitment/published', type='json', auth="admin")
def published (self, **post):
@ -110,4 +150,4 @@ class website_hr_recruitment(http.Controller):
res = hr_job.write(request.cr, request.uid, [rec.id], vals)
obj = hr_job.browse(request.cr, request.uid, id)
return { 'count': obj.no_of_recruitment, 'state': obj.state, 'published': obj.website_published }
# vim:expandtab:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,34 +1,4 @@
$(function () {
$(document).on('click', 'button[name=subscribe]', function (e) {
var div = $(this).parent();
var parent = $(this).parent().parent();
var groupid = $(this).siblings('input[name=group_id]').val();
var id = $(this).parent().parent().attr('id');
var email = $(this).siblings('div').find('input[name=email]').val();
if (!email) return;
openerp.jsonRpc('/recruitment/message_get_subscribed', 'call', {'email': email, 'id': id, 'mail_group_id': groupid}).then(function (result) {
if (result == 1) {
div.removeClass('show').addClass('hidden');
parent.find('div:gt(0)').find('input[type=hidden][name=email]').val(email);
parent.find('div:gt(0)').removeClass('hidden');
}
});
// $(this).siblings('div').find('input[name=email]').attr("value", "");
});
$(document).on('click', 'button[name=unsubscribe]', function (e) {
var div = $(this).parent();
var parent = $(this).parent().parent();
var id = $(this).parent().parent().attr('id');
var groupid = $(this).siblings('input[name=group_id]').val();
openerp.jsonRpc('/recruitment/message_get_unsubscribed', 'call', {'email': $(this).siblings('input[name=email]').val(), 'id': id, 'mail_group_id': groupid}).then(function (result) {
if (result == 1) {
parent.find('div:first').removeClass('hidden').addClass('show');
div.addClass('hidden');
}
});
});
$(document).on('click', '.js_publish', function (e) {
var id = $(this).data('id');
var row = $(this).parents().find('tr#'+id);

View File

@ -7,100 +7,100 @@
<field name="description">Job Posts on your website</field>
</record>
<template id="job_footer_custom" inherit_id="website.layout" name="Custom Footer Job">
<xpath expr="//body/footer//a[@href='/page/website.aboutus']" position="after">
<xpath expr="//body/footer//div[@name='info']/ul" position="inside">
<li><a href="/jobs">Jobs</a></li>
</xpath>
</template>
<template id="index" name="Jobs">
<template id="index" name="Jobs" page="True">
<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">
<h1>Job Position</h1>
<t t-if="no_of_jobs &gt; 0">
<t t-call="website.pager">
<t t-set="classname">pull-left</t>
</t>
<t t-foreach="companies" t-as="company">
<h2 class="text-center"><t t-field="company.name"/></h2>
<table class="table">
<thead>
<tr>
<th><h4>Post Name</h4></th>
<th/>
</tr>
</thead>
<tbody>
<t t-foreach="res_job" t-as="job">
<tr t-if="job.company_id.id==company.id" t-att-id="job.id">
<td>
<t t-if="job.department_id">
<a t-att-href="'/job/detail/%%s' %% job.id"><span class="lead" t-field="job.department_id.name"></span></a>
</t>
<t t-if="not job.department_id">
<a t-att-href="'/job/detail/%%s' %% job.id"><span class="lead" t-field="job.name"></span></a>
</t>
<br/>
<i class="icon-time"></i> <t t-esc="vals[job.id]['date_recruitment']"/><br/>
<span id='counting' t-att-class="job.no_of_recruitment &gt; 0 and 'show' or 'hidden'" style="position:absolute;">
<i class="icon-group"></i> No.of Post:
<span id='counting_num'>
<t t-esc="vals[job.id]['count']"></t>
</span>
</span>
<span id="norecruit" t-att-class="job.no_of_recruitment &lt; 1 and 'show' or 'hidden'" style="position:absolute;">
Right now no recruitment is going on.
</span>
<br/>
<span><i class="icon-map-marker"></i> <t t-field="res_company.city"/>
<t t-if="res_company.state_id">
<span t-field="res_company.state_id.name"></span>
</t>
<t t-if="res_company.country_id">
<span t-field="res_company.country_id.name"></span>
</t><br/>
<t t-if="res_company.phone">&amp;#x2706; <t t-field="res_company.phone"/></t></span>
</td>
<td><t t-call="website.publish"><t t-set="object" t-value="job"/></t></td>
</tr>
</t>
</tbody>
</table>
</t>
</t>
<t t-if="no_of_jobs &lt; 1">
<h3>"Thank you for your interest, but right now there is no job openings available in our company."</h3>
</t>
</div>
<div id="wrap">
<div class="oe_structure">
<h1 class="text-center">Job Position</h1>
</div>
<div class="container">
<div class="row">
<div class="col-md-4 css_noprint" id="left_column">
<ul class="nav nav-pills nav-stacked">
<li class="nav-header">Departments</li>
<t t-foreach="departments" t-as="department">
<li t-att-class="department.id == active and 'active' or ''">
<a t-attf-href="/department/#{ department.id }/" ><t t-field="department.name"/></a>
</li>
</t>
</ul>
</div>
<div class="col-md-8">
<t t-call="website.pager" >
<t t-set="classname">pull-left</t>
</t>
</div>
<div class="col-md-8">
<ul class="media-list">
<li t-foreach="res_job" t-as="job" class="media" data-publish="">
<t t-call="website.publish"><t t-set="object" t-value="job"/></t>
<div class="media-body">
<span t-if="not job.no_of_recruitment" class="label label-default pull-right">No recruitment needed.</span>
<t t-if="job.no_of_recruitment">
<span class="label label-default pull-right label-info"><t t-esc="vals[job.id]['count']"/> Recruitment availables.</span>
</t>
<h4 class="media-heading"><a t-attf-href="/job/detail/#{ job.id }/"><span t-field="job.name"> </span></a></h4>
<div>
<i class="icon-time"></i> <span t-esc="vals[job.id]['date_recruitment']"> </span>
</div>
<div t-if="companies[0].country_id">
<i class="icon-map-marker"></i> <span t-field="companies[0].city"> </span> <span t-if="companies[0].state_id" t-field="companies[0].state_id.name"> </span>, <span t-field="companies[0].country_id.name"> </span>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>
<div class="oe_structure"/>
</div>
</t>
</template>
<template id="detail">
<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">Job Detail</t>
<div class="col-md-4 pull-right">
<ul class="pager">
<li><a t-att-href="'/jobs'">All Jobs</a></li>
</ul>
</div>
<div class="container">
<h1 t-field="job.name"></h1>
<div class="row">
<div class="col-md-12">
<t t-if="job.description">
<p t-field="job.description"></p>
</t>
<t t-if="job.requirements">
<h4>Requirements</h4>
<p t-field="job.requirements"></p>
</t>
</div>
</div>
<t t-call="website_hr_recruitment.applyjobpost"/>
</div>
<div class="col-md-4 pull-right">
<ul class="pager">
<li><a t-att-href="'/jobs'">All Jobs</a></li>
</ul>
</div>
<div id="wrap">
<div class="oe_structure">
<h1 class="text-center" t-field="job.name"></h1>
<h4 class="text-center">
<i class="icon-time"></i> <span><t t-esc="vals_date"/></span>
</h4>
<h5 class="text-center">
<i class="icon-map-marker"></i> <span t-field="job.company_id.city"> </span> <span t-if="job.company_id.state_id" t-field="job.company_id.state_id.name"> </span>, <span t-field="job.company_id.country_id.name"> </span></h5>
</div>
<div class="container">
<t t-call="website.publish"><t t-set="object" t-value="job"/></t>
<hr/>
<div class="row">
<div class="pull-left">
</div>
<h4>Description</h4>
<p t-field="job.description"></p>
<h4>Requirements</h4>
<p t-field="job.requirements"></p>
<t t-call="website_hr_recruitment.applyjobpost"/>
</div>
</div>
</div>
</t>
</template>
<template id="applyjobpost">
@ -163,4 +163,4 @@
</t>
</template>
</data>
</openerp>
</openerp>