[IMP] Added the default text when no job positions were there
added subscribe / unsubscribe for jobs. bzr revid: psa@tinyerp.com-20130813133830-iziax15rdkebfj55
This commit is contained in:
@@ -8,21 +8,72 @@ from urllib import quote_plus
|
||||
class website_hr_recruitment(http.Controller):
|
||||
|
||||
@http.route(['/jobs'], type='http', auth="public")
|
||||
def career(self, **post):
|
||||
def jobs(self, mail_group_id=None, job_id=None, **post):
|
||||
website = request.registry['website']
|
||||
jobpost_ids = request.registry['hr.job'].search(request.cr, request.uid, [("state", "=", 'recruit')])
|
||||
hr_job_obj = request.registry['hr.job']
|
||||
group_obj = request.registry['mail.group']
|
||||
user_obj = request.registry['res.users']
|
||||
|
||||
jobpost_ids = hr_job_obj.search(request.cr, request.uid, [("state", 'in', ['recruit', 'open'])])
|
||||
request.cr.execute("select distinct(com.id) from hr_job job, res_company com where com.id=job.company_id")
|
||||
ids = []
|
||||
ids = []
|
||||
for i in request.cr.fetchall():
|
||||
ids.append(i[0])
|
||||
companies = request.registry['res.company'].browse(request.cr, request.uid, ids)
|
||||
values = website.get_rendering_context({
|
||||
'companies': companies,
|
||||
'res_job': request.registry['hr.job'].browse(request.cr, request.uid, jobpost_ids)
|
||||
'res_job': hr_job_obj.browse(request.cr, request.uid, jobpost_ids),
|
||||
'subscribe': post.get('subscribe'),
|
||||
'job_id': None,
|
||||
'no_of_jobs': len(hr_job_obj.browse(request.cr, request.uid, jobpost_ids)),
|
||||
})
|
||||
if request.uid != website.get_public_user().id and mail_group_id:
|
||||
message_follower_ids = group_obj.read(request.cr, request.uid, [mail_group_id], ['message_follower_ids'])[0]['message_follower_ids']
|
||||
parent_id = user_obj.browse(request.cr, SUPERUSER_ID, request.uid).partner_id.id
|
||||
values['subscribe'] = parent_id in message_follower_ids
|
||||
|
||||
if job_id:
|
||||
values['job_id'] = hr_job_obj.browse(request.cr, request.uid, job_id)
|
||||
|
||||
html = website.render("website_hr_recruitment.jobs", values)
|
||||
return html
|
||||
|
||||
@http.route(['/jobs/subscribe'], type='http', auth="public")
|
||||
def subscribe(self, mail_group_id=None, **post):
|
||||
website = request.registry['website']
|
||||
partner_obj = request.registry['res.partner']
|
||||
group_obj = request.registry['mail.group']
|
||||
user_obj = request.registry['res.users']
|
||||
|
||||
if mail_group_id and 'subscribe' in post and (post.get('email') or request.uid != website.get_public_user().id):
|
||||
if request.uid == website.get_public_user().id:
|
||||
partner_ids = partner_obj.search(request.cr, SUPERUSER_ID, [("email", "=", post.get('email'))])
|
||||
if not partner_ids:
|
||||
partner_ids = [partner_obj.create(request.cr, SUPERUSER_ID, {"email": post.get('email'), "name": "Subscribe: %s" % post.get('email')})]
|
||||
else:
|
||||
partner_ids = [user_obj.browse(request.cr, request.uid, request.uid).partner_id.id]
|
||||
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 self.jobs(mail_group_id=mail_group_id, subscribe=post.get('email'))
|
||||
|
||||
@http.route(['/jobs/unsubscribe'], type='http', auth="public")
|
||||
def unsubscribe(self, mail_group_id=None, **post):
|
||||
website = request.registry['website']
|
||||
partner_obj = request.registry['res.partner']
|
||||
group_obj = request.registry['mail.group']
|
||||
user_obj = request.registry['res.users']
|
||||
|
||||
if mail_group_id and 'unsubscribe' in post and (post.get('email') or request.uid != website.get_public_user().id):
|
||||
if request.uid == website.get_public_user().id:
|
||||
partner_ids = partner_obj.search(request.cr, SUPERUSER_ID, [("email", "=", post.get('email'))])
|
||||
else:
|
||||
partner_ids = [user_obj.browse(request.cr, request.uid, request.uid).partner_id.id]
|
||||
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 self.jobs(mail_group_id=mail_group_id, subscribe=None)
|
||||
|
||||
@http.route(['/job/detail/<id>'], type='http', auth="public")
|
||||
def detail(self, id=0):
|
||||
id = id and int(id) or 0
|
||||
|
||||
@@ -20,33 +20,57 @@
|
||||
<div class="page-header">
|
||||
<h1>Job Position</h1>
|
||||
</div>
|
||||
<t t-foreach="companies" t-as="company">
|
||||
<div class="page-header">
|
||||
<h1 class="text-center"><t t-esc="company.name"/></h1>
|
||||
</div>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Post Name</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<t t-foreach="res_job" t-as="job">
|
||||
<tr t-if="job.company_id.id==company.id">
|
||||
<td>
|
||||
<a t-att-href="'/job/detail/%%s' %% job.id"><span class="lead" t-field="job.name"/></a><br/>
|
||||
<b><span t-if="job.department_id" t-esc="job.department_id.name"/></b><br/>
|
||||
<span><b>No of Position:</b> <t t-esc="int(job.no_of_recruitment)"/></span><br/>
|
||||
<span t-esc="job.write_date"/>
|
||||
</td>
|
||||
<td>
|
||||
<span><b>Location:</b> <t t-esc="res_company.city+','"/> <t t-esc="res_company.state_id.name+','"/> <t t-esc="res_company.country_id.name+'.'"/></span><br/>
|
||||
<span>&#x2706; <t t-esc="res_company.phone+'.'"/></span>
|
||||
</td>
|
||||
<t t-if="no_of_jobs > 0">
|
||||
<t t-foreach="companies" t-as="company">
|
||||
<div class="page-header">
|
||||
<h2 class="text-center"><t t-field="company.name"/></h2>
|
||||
</div>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><h4>Post Name</h4></th>
|
||||
</tr>
|
||||
</t>
|
||||
</tbody>
|
||||
</table>
|
||||
</thead>
|
||||
<tbody>
|
||||
<t t-foreach="res_job" t-as="job">
|
||||
<tr t-if="job.company_id.id==company.id">
|
||||
<td>
|
||||
<a t-att-href="'/job/detail/%%s' %% job.id"><span class="lead" t-field="job.name"/></a><br/>
|
||||
<b><span t-if="job.department_id" t-esc="job.department_id.name"/></b><br/>
|
||||
<span><t t-if="int(job.no_of_recruitment) > 0"><b>No of Position:</b> <t t-esc="int(job.no_of_recruitment)"/></t><t t-if="int(job.no_of_recruitment) < 1"><b>Right now no recruitment is going on.</b></t></span><br/><br/>
|
||||
<span t-esc="job.write_date"/>
|
||||
<span><t t-if="int(job.no_of_recruitment) > 0"><b>Location:</b> <t t-esc="res_company.city+','"/> <t t-esc="res_company.state_id.name+','"/> <t t-esc="res_company.country_id.name"/><br/>
|
||||
&#x2706; <t t-esc="res_company.phone"/></t></span>
|
||||
|
||||
<div t-if="int(job.no_of_recruitment) < 1">
|
||||
<strong>You may also be interested in our others job positions, for which we don't have availabilities right now.<br/>
|
||||
Follow the positions that interests you and we will send you an email when the position is available.</strong><br/><br/>
|
||||
<form action="/jobs/subscribe" method="POST" class="form-inline span8" t-if="not subscribe">
|
||||
<input placeholder="Email Address" type="email" name="email" class="input-medium"/>
|
||||
<button type="submit" class="btn btn-primary" name="subscribe">Subscribe</button>
|
||||
</form>
|
||||
<form class="span8" action="/jobs/unsubscribe" method="POST" t-if="subscribe">
|
||||
<div class="alert alert-success">
|
||||
<button type="button" class="close" data-dismiss="alert">×</button>
|
||||
<strong>Oh great!</strong> You are successfully subscribed email notifications for a <b><t t-esc="job.name"/></b> job.
|
||||
</div>
|
||||
<input type="hidden" name="email" t-att-value="subscribe"/>
|
||||
<button type="submit" class="btn" name="unsubscribe">Unsubscribe</button>
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<button type="submit" class="btn label-important js_publish pull-right" name="publish">Publish</button>
|
||||
<button type="submit" class="btn label label-success js_unpublish hidden" name="unpublish">Unpublish</button>
|
||||
</td>
|
||||
</tr>
|
||||
</t>
|
||||
</tbody>
|
||||
</table>
|
||||
</t>
|
||||
</t>
|
||||
<t t-if="no_of_jobs < 1">
|
||||
<h3>"Thank you for your interest, but right now there is no job openings available in our company. Please check back after some time."</h3>
|
||||
</t>
|
||||
</div>
|
||||
</t>
|
||||
@@ -67,7 +91,7 @@
|
||||
<div class="span12">
|
||||
<t t-if="job.description">
|
||||
<h3>Description</h3>
|
||||
<p t-if="job.description"><t t-esc="job.description"/></p>
|
||||
<p t-if="job.description"><t t-field="job.description"/></p>
|
||||
</t>
|
||||
</div>
|
||||
</div>
|
||||
@@ -113,7 +137,7 @@
|
||||
<t t-set="title">Thank You!</t>
|
||||
<div class="span4 pull-right">
|
||||
<ul class="pager">
|
||||
<li><a t-att-href="'/job/detail/%%s' %% jobid">Back</a></li>
|
||||
<li><a t-att-href="'/job/detail/%%s' %% jobid">All Jobs</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<section id="typography">
|
||||
|
||||
Reference in New Issue
Block a user