[IMP]Added subscribed/unsubscribed.
bzr revid: bth@tinyerp.com-20130821133927-er9tpo9hucwo5ylg
This commit is contained in:
parent
78314bd805
commit
26d3154f2d
|
@ -1,5 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from openerp.addons.web import http
|
||||
from openerp import SUPERUSER_ID
|
||||
from openerp.addons.web.http import request
|
||||
import base64
|
||||
import simplejson
|
||||
|
@ -43,7 +44,6 @@ class website_hr_recruitment(http.Controller):
|
|||
|
||||
if job_id:
|
||||
values['job_id'] = hr_job_obj.browse(request.cr, request.uid, job_id)
|
||||
|
||||
return website.render("website_hr_recruitment.index", values)
|
||||
|
||||
@http.route(['/jobs/subscribe'], type='http', auth="public")
|
||||
|
@ -130,4 +130,22 @@ class website_hr_recruitment(http.Controller):
|
|||
obj = hr_job.browse(request.cr, request.uid, id)
|
||||
return { 'published': obj.website_published and "1" or "0", 'count': obj.no_of_recruitment }
|
||||
|
||||
@http.route('/recruitment/message_get_subscribed', type='json', auth="admin")
|
||||
def message_get_subscribed(self, email, id):
|
||||
hr_job = request.registry['hr.job']
|
||||
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})]
|
||||
hr_job.write(request.cr, request.uid, [id], {'message_follower_ids': partner_ids})
|
||||
return 1
|
||||
|
||||
@http.route('/recruitment/message_get_unsubscribed', type='json', auth="admin")
|
||||
def message_get_unsubscribed(self, email, id):
|
||||
hr_job = request.registry['hr.job']
|
||||
partner_obj = request.registry['res.partner']
|
||||
partner_ids = partner_obj.search(request.cr, SUPERUSER_ID, [("email", "=", email)])
|
||||
hr_job.write(request.cr, request.uid, [id], {'message_follower_ids': []})
|
||||
return 1
|
||||
|
||||
# vim:expandtab:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -1,4 +1,26 @@
|
|||
$(function () {
|
||||
$(document).on('click', 'button[name=subscribe]', function (e) {
|
||||
div = $(this).parent();
|
||||
parent = $(this).parent().parent();
|
||||
id = $(this).parent().parent().attr('id');
|
||||
openerp.jsonRpc('/recruitment/message_get_subscribed', 'call', {'email': $(this).siblings('input[name=email]').val(), 'id': id}).then(function (result) {
|
||||
if (result == 1) {
|
||||
div.hide();
|
||||
parent.find('.hidden').removeClass('hidden');
|
||||
}
|
||||
});
|
||||
});
|
||||
$(document).on('click', 'button[name=unsubscribe]', function (e) {
|
||||
div = $(this).parent();
|
||||
parent = $(this).parent().parent();
|
||||
id = $(this).parent().parent().attr('id');
|
||||
openerp.jsonRpc('/recruitment/message_get_unsubscribed', 'call', {'email': $(this).siblings('input[name=email]').val(), 'id': id}).then(function (result) {
|
||||
if (result == 1) {
|
||||
parent.find('.subscribedetails').show();
|
||||
div.addClass('hidden');
|
||||
}
|
||||
});
|
||||
});
|
||||
$(document).on('click', '.js_published, .js_unpublished', function (e) {
|
||||
e.preventDefault();
|
||||
var $link = $(this).parent();
|
||||
|
|
|
@ -60,21 +60,22 @@
|
|||
<span t-field="res_company.country_id.name"></span>
|
||||
</t><br/>
|
||||
<t t-if="res_company.phone">&#x2706; <t t-field="res_company.phone"/></t></span>
|
||||
<div t-if="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">
|
||||
<div t-if="job.no_of_recruitment < 1" t-att-id="job.id">
|
||||
<div class="subscribedetails">
|
||||
<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/>
|
||||
<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">
|
||||
<button class="btn btn-primary" name="subscribe">Subscribe</button>
|
||||
<input type="hidden" name="recid" t-att-value="job.id"/>
|
||||
</div>
|
||||
<div class="hidden">
|
||||
<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>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
|
|
Loading…
Reference in New Issue