[FIX] website: can choose an other controller to publish data. Website sale: add a contraint for address and organizer for publish an event. Auto publish address and organizer in front end. Clean website_hr_recruitment publisher
bzr revid: chm@openerp.com-20131104155230-j36l2e1fez0vnkwi
This commit is contained in:
parent
a295fd4ada
commit
bfc8f61984
|
@ -155,7 +155,6 @@
|
|||
<field name="type" ref="event_type_4"/>
|
||||
<field name="user_id" ref="base.user_root"/>
|
||||
<field name="address_id" ref="base.res_partner_2"/>
|
||||
<field name="organizer_id" ref="base.res_partner_address_4"/>
|
||||
<field name="description"><![CDATA[
|
||||
<div class="oe_structure">
|
||||
<center><strong>5-days Technical Training</strong></center>
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import base64
|
||||
import cStringIO
|
||||
import contextlib
|
||||
import hashlib
|
||||
|
|
|
@ -117,6 +117,16 @@
|
|||
return all_ready;
|
||||
};
|
||||
|
||||
website.error = function(data, url) {
|
||||
var $error = $(openerp.qweb.render('website.error_dialog', {
|
||||
'title': data.data ? data.data.arguments[0] : data.statusText,
|
||||
'message': data.data ? data.data.arguments[1] : "",
|
||||
'backend_url': url
|
||||
}));
|
||||
$error.appendTo("body");
|
||||
$error.modal('show');
|
||||
};
|
||||
|
||||
dom_ready.then(function () {
|
||||
|
||||
/* ----- PUBLISHING STUFF ---- */
|
||||
|
@ -135,11 +145,13 @@
|
|||
|
||||
$(document).on('click', '.js_publish', function (e) {
|
||||
e.preventDefault();
|
||||
var $data = $(":first", this).parents("[data-publish]");
|
||||
$data.attr("data-publish", $data.first().attr("data-publish") == 'off' ? 'on' : 'off');
|
||||
openerp.jsonRpc('/website/publish', 'call', {'id': $(this).data('id'), 'object': $(this).data('object')})
|
||||
var $a = $(this);
|
||||
var $data = $a.find(":first").parents("[data-publish]");
|
||||
openerp.jsonRpc($a.data('controller') || '/website/publish', 'call', {'id': +$a.data('id'), 'object': $a.data('object')})
|
||||
.then(function (result) {
|
||||
$data.attr("data-publish", +result ? 'on' : 'off');
|
||||
}).fail(function (err, data) {
|
||||
website.error(data, '/web#model='+$a.data('object')+'&id='+$a.data('id'));
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -151,11 +163,13 @@
|
|||
$data.toggleClass("css_unpublish css_publish");
|
||||
$btn.removeClass("btn-default btn-success");
|
||||
|
||||
openerp.jsonRpc('/website/publish', 'call', {'id': +$data.data('id'), 'object': $data.data('object')})
|
||||
openerp.jsonRpc($data.data('controller') || '/website/publish', 'call', {'id': +$data.data('id'), 'object': $data.data('object')})
|
||||
.then(function (result) {
|
||||
$btn.toggleClass("btn-default", !result).toggleClass("btn-success", result);
|
||||
$data.toggleClass("css_unpublish", !result).toggleClass("css_publish", result);
|
||||
$data.parents("[data-publish]").attr("data-publish", +result ? 'on' : 'off');
|
||||
}).fail(function (err, data) {
|
||||
website.error(data, '/web#model='+$data.data('object')+'&id='+$data.data('id'));
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -61,4 +61,27 @@
|
|||
</div>
|
||||
</t>
|
||||
|
||||
<t t-name="website.error_dialog">
|
||||
<div class="modal fade" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button title="Close" type="button" class="close" data-dismiss="modal">×</button>
|
||||
<div class="h2"><t t-esc="title"/></div>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<section>
|
||||
<t t-esc="message"/>
|
||||
</section>
|
||||
<section class="mt32">
|
||||
You have encountered an error. You can edit in the <a t-att-href="backend_url">backend</a> this data.
|
||||
</section>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" data-dismiss="modal" href="#" class="close btn btn-default">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
</templates>
|
||||
|
|
|
@ -267,7 +267,7 @@
|
|||
<template id="publish_management">
|
||||
<t t-if="editable" t-ignore="true">
|
||||
<div class="pull-right">
|
||||
<div t-attf-class="btn-group dropdown js_publish_management #{object.id and object.website_published and 'css_publish' or 'css_unpublish'}" t-att-data-id="object.id" t-att-data-object="object._name">
|
||||
<div t-attf-class="btn-group dropdown js_publish_management #{object.id and object.website_published and 'css_publish' or 'css_unpublish'}" t-att-data-id="object.id" t-att-data-object="object._name" t-att-data-controller="publish_controller">
|
||||
<a t-attf-class="btn btn-sm btn-#{object.id and object.website_published and 'success' or 'default'}" t-att-id="'dopprod-%s' % object.id" role="button" data-toggle="dropdown">Options <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu" role="menu" t-att-aria-labelledby="'dopprod-%s' % object.id">
|
||||
<t t-raw="0"/>
|
||||
|
|
|
@ -15,6 +15,7 @@ Online Events
|
|||
'data': [
|
||||
'data/event_data.xml',
|
||||
'views/website_event.xml',
|
||||
'views/website_event_sale_backend.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'security/website_event.xml',
|
||||
],
|
||||
|
|
|
@ -25,6 +25,9 @@ from openerp.addons.web.http import request
|
|||
from openerp.tools.translate import _
|
||||
from openerp.addons import website_sale
|
||||
from openerp.addons.website.models import website
|
||||
from openerp.addons.website.controllers.main import Website as controllers
|
||||
controllers = controllers()
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
@ -216,3 +219,15 @@ class website_event(http.Controller):
|
|||
if not _values:
|
||||
return request.redirect("/event/%s/" % event_id)
|
||||
return request.redirect("/shop/checkout")
|
||||
|
||||
@website.route(['/event/publish'], type='json', auth="public")
|
||||
def publish(self, id, object):
|
||||
# if a user publish an event, he publish all linked res.partner
|
||||
event = request.registry[object].browse(request.cr, request.uid, int(id))
|
||||
if not event.website_published:
|
||||
if event.organizer_id and not event.organizer_id.website_published:
|
||||
event.organizer_id.write({'website_published': True})
|
||||
if event.address_id and not event.address_id.website_published:
|
||||
event.address_id.write({'website_published': True})
|
||||
|
||||
return controllers.publish(id, object)
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
<record id="menu_events" model="website.menu">
|
||||
<field name="name">Events</field>
|
||||
<field name="url">/events</field>
|
||||
<field name="url">/event</field>
|
||||
<field name="parent_id" ref="website.main_menu"/>
|
||||
</record>
|
||||
<record id="action_open_website" model="ir.actions.act_url">
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="base.res_partner_6" model="res.partner">
|
||||
<field name="website_published">True</field>
|
||||
</record>
|
||||
<record id="event.event_0" model="event.event">
|
||||
<field name="website_published">True</field>
|
||||
<field name="twitter_hashtag">openerp</field>
|
||||
|
@ -162,6 +165,9 @@
|
|||
</div>
|
||||
]]></field> </record>
|
||||
|
||||
<record id="base.res_partner_5" model="res.partner">
|
||||
<field name="website_published">True</field>
|
||||
</record>
|
||||
<record id="event.event_1" model="event.event">
|
||||
<field name="website_published">True</field>
|
||||
<field name="twitter_hashtag">openerp</field>
|
||||
|
@ -323,11 +329,20 @@
|
|||
]]></field>
|
||||
</record>
|
||||
|
||||
<record id="base.res_partner_14" model="res.partner">
|
||||
<field name="website_published">True</field>
|
||||
</record>
|
||||
<record id="event.event_2" model="event.event">
|
||||
<field name="website_published">True</field>
|
||||
<field name="twitter_hashtag">openerp</field>
|
||||
</record>
|
||||
|
||||
<record id="base.res_partner_2" model="res.partner">
|
||||
<field name="website_published">True</field>
|
||||
</record>
|
||||
<record id="base.res_partner_address_4" model="res.partner">
|
||||
<field name="website_published">True</field>
|
||||
</record>
|
||||
<record id="event.event_3" model="event.event">
|
||||
<field name="website_published">True</field>
|
||||
<field name="twitter_hashtag">openerp</field>
|
||||
|
|
|
@ -51,6 +51,21 @@ class event(osv.osv):
|
|||
'website_published': False,
|
||||
}
|
||||
|
||||
def _check_organizer_id_published(self, cr, uid, ids, context=None):
|
||||
for obj in self.browse(cr, uid, ids, context=context):
|
||||
if obj.website_published and obj.organizer_id and not obj.organizer_id.website_published:
|
||||
return False
|
||||
return True
|
||||
def _check_address_id_published(self, cr, uid, ids, context=None):
|
||||
for obj in self.browse(cr, uid, ids, context=context):
|
||||
if obj.website_published and obj.address_id and not obj.address_id.website_published:
|
||||
return False
|
||||
return True
|
||||
_constraints = [
|
||||
(_check_organizer_id_published, "This event can't be published if the field Orginizer is not website published.", ['organizer_id','website_published']),
|
||||
(_check_address_id_published, "This event can't be published if the field Location is not website published.", ['address_id','website_published']),
|
||||
]
|
||||
|
||||
def google_map_img(self, cr, uid, ids, zoom=8, width=298, height=298, context=None):
|
||||
partner = self.browse(cr, uid, ids[0], context=context)
|
||||
if partner.address_id:
|
||||
|
|
|
@ -45,7 +45,10 @@
|
|||
</div>
|
||||
<ul class="media-list">
|
||||
<li t-foreach="event_ids" t-as="event" class="media" data-publish="">
|
||||
<t t-call="website.publish_management"><t t-set="object" t-value="event"/></t>
|
||||
<t t-call="website.publish_management">
|
||||
<t t-set="object" t-value="event"/>
|
||||
<t t-set="publish_controller">/event/publish</t>
|
||||
</t>
|
||||
<div class="media-body">
|
||||
<span t-if="not event.event_ticket_ids" class="label label-danger pull-right">Registration Closed</span>
|
||||
<t t-if="event.event_ticket_ids">
|
||||
|
@ -174,7 +177,11 @@
|
|||
<ul class="media-list" id="comment">
|
||||
<li t-foreach="event_id.website_message_ids" t-as="comment" class="media">
|
||||
<div class="media-body">
|
||||
<t t-call="website.publish_management"><t t-set="object" t-value="comment"/></t>
|
||||
<t t-call="website.publish_management">
|
||||
<t t-set="object" t-value="comment"/>
|
||||
<t t-set="publish_edit" t-value="True"/>
|
||||
<t t-set="publish_controller">/event/publish</t>
|
||||
</t>
|
||||
<t t-raw="comment.body"/>
|
||||
<small class="pull-right muted text-right">
|
||||
<div t-field="comment.author_id"/>
|
||||
|
@ -189,7 +196,11 @@
|
|||
|
||||
<div class="panel panel-default" t-if="event_id.address_id">
|
||||
<div class="panel-heading">
|
||||
<t t-call="website.publish_management"><t t-set="object" t-value="event_id"/></t>
|
||||
<t t-call="website.publish_management">
|
||||
<t t-set="object" t-value="event_id"/>
|
||||
<t t-set="publish_edit" t-value="True"/>
|
||||
<t t-set="publish_controller">/event/publish</t>
|
||||
</t>
|
||||
<h4>Where</h4>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record model="ir.ui.view" id="view_event_form">
|
||||
<field name="name">event.event.website.form</field>
|
||||
<field name="model">event.event</field>
|
||||
<field name="inherit_id" ref="event_sale.view_event_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="organizer_id" position="after">
|
||||
<field name="website_published"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -2,6 +2,9 @@
|
|||
from openerp.addons.web import http
|
||||
from openerp.addons.web.http import request
|
||||
from openerp.addons.website.models import website
|
||||
from openerp.addons.website.controllers.main import Website as controllers
|
||||
controllers = controllers()
|
||||
|
||||
import base64
|
||||
|
||||
|
||||
|
@ -68,7 +71,6 @@ class website_hr_recruitment(http.Controller):
|
|||
'res_id': id
|
||||
}
|
||||
request.registry['ir.attachment'].create(request.cr, request.uid, attachment_values)
|
||||
website = request.registry['website']
|
||||
values = {
|
||||
'jobid': post['job_id']
|
||||
}
|
||||
|
@ -78,13 +80,14 @@ class website_hr_recruitment(http.Controller):
|
|||
def applyjobpost(self, job=None, **kwargs):
|
||||
return request.website.render("website_hr_recruitment.applyjobpost", { 'job': job })
|
||||
|
||||
@website.route('/recruitment/published', type='json', auth="admin", multilang=True)
|
||||
def published (self, id, **post):
|
||||
hr_job = request.registry['hr.job']
|
||||
@website.route('/job/publish', type='json', auth="admin", multilang=True)
|
||||
def publish (self, id, object):
|
||||
res = controllers.publish(id, object)
|
||||
|
||||
hr_job = request.registry[object]
|
||||
id = int(id)
|
||||
rec = hr_job.browse(request.cr, request.uid, id)
|
||||
vals = {}
|
||||
|
||||
if rec.website_published:
|
||||
vals['state'] = 'recruit'
|
||||
if not rec.no_of_recruitment:
|
||||
|
@ -93,6 +96,5 @@ class website_hr_recruitment(http.Controller):
|
|||
vals['state'] = 'open'
|
||||
hr_job.write(request.cr, request.uid, [rec.id], vals, context=request.context)
|
||||
|
||||
obj = hr_job.browse(request.cr, request.uid, id, context=request.context)
|
||||
return { 'count': obj.no_of_recruitment, 'state': obj.state, 'published': obj.website_published }
|
||||
return res
|
||||
# vim:expandtab:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
$(function () {
|
||||
$(this).ajaxComplete(function(event, xhr, settings) {
|
||||
var data = JSON.parse(settings.data).params;
|
||||
if (settings.url == "/website/publish") {
|
||||
var $data = $(".oe_website_hr_recruitment .js_publish_management[data-id='" + data.id + "'][data-object='" + data.object + "']");
|
||||
if ($data.length) {
|
||||
settings.jsonpCallback = openerp.jsonRpc('/recruitment/published', 'call', data);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
|
@ -53,10 +53,6 @@
|
|||
|
||||
<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="additional_title">Job Detail</t>
|
||||
<div id="wrap">
|
||||
<div class="container oe_website_hr_recruitment">
|
||||
|
@ -70,6 +66,7 @@
|
|||
<t t-call="website.publish_management">
|
||||
<t t-set="object" t-value="job"/>
|
||||
<t t-set="publish_edit" t-value="True"/>
|
||||
<t t-set="publish_controller">/job/publish</t>
|
||||
</t>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue