[MERGE] Sync with trunk-website-al
bzr revid: rim@openerp.com-20140128143445-tse97tsr0yvubv0y
This commit is contained in:
commit
8c00a0125c
|
@ -22,9 +22,11 @@ import logging
|
|||
|
||||
import openerp
|
||||
import openerp.addons.web.controllers.main as webmain
|
||||
from openerp.addons.auth_signup.res_users import SignupError
|
||||
from openerp import http
|
||||
from openerp.http import request, LazyResponse
|
||||
from openerp.tools.translate import _
|
||||
from openerp.tools import exception_to_unicode
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -77,15 +79,22 @@ class Home(openerp.addons.web.controllers.main.Home):
|
|||
res_users.reset_password(request.cr, openerp.SUPERUSER_ID, login)
|
||||
qcontext['message'] = _("An email has been sent with credentials to reset your password")
|
||||
response.params['template'] = 'web.login'
|
||||
except:
|
||||
except Exception:
|
||||
qcontext['error'] = _("Could not reset your password")
|
||||
_logger.exception('error when resetting password')
|
||||
else:
|
||||
values = dict((key, qcontext.get(key)) for key in ('login', 'name', 'password'))
|
||||
res_users.signup(request.cr, openerp.SUPERUSER_ID, values, token)
|
||||
request.cr.commit()
|
||||
try:
|
||||
self._signup_with_values(token, values)
|
||||
request.cr.commit()
|
||||
except SignupError, e:
|
||||
qcontext['error'] = exception_to_unicode(e)
|
||||
return super(Home, self).web_login(*args, **kw)
|
||||
|
||||
return response
|
||||
|
||||
def _signup_with_values(self, token, values):
|
||||
request.registry['res.users'].signup(request.cr, openerp.SUPERUSER_ID, values, token)
|
||||
|
||||
|
||||
# vim:expandtab:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -122,9 +122,9 @@
|
|||
</group>
|
||||
<group name="Weights" position="after">
|
||||
<group name="store" groups="stock.group_locations" string="Counter-Part Locations Properties">
|
||||
<field name="property_stock_procurement" attrs="{'readonly':['|', '|', ('type','=','service'), ('is_only_child', '=', False), ('is_only_child', '=', False)]}" domain="[('usage','=','procurement')]"/>
|
||||
<field name="property_stock_production" attrs="{'readonly':['|', '|', ('type','=','service'), ('is_only_child', '=', False), ('is_only_child', '=', False)]}" domain="[('usage','=','production')]"/>
|
||||
<field name="property_stock_inventory" attrs="{'readonly':['|', '|', ('type','=','service'), ('is_only_child', '=', False), ('is_only_child', '=', False)]}" domain="[('usage','=','inventory')]"/>
|
||||
<field name="property_stock_procurement" attrs="{'readonly':['|', ('type','=','service'), ('is_only_child', '=', False) ]}" domain="[('usage','=','procurement')]"/>
|
||||
<field name="property_stock_production" attrs="{'readonly':['|', ('type','=','service'), ('is_only_child', '=', False) ]}" domain="[('usage','=','production')]"/>
|
||||
<field name="property_stock_inventory" attrs="{'readonly':['|', ('type','=','service'), ('is_only_child', '=', False) ]}" domain="[('usage','=','inventory')]"/>
|
||||
</group>
|
||||
</group>
|
||||
<field name="product_manager" position="attributes" version="7.0">
|
||||
|
|
|
@ -28,7 +28,7 @@ class stock_fill_inventory(osv.osv_memory):
|
|||
_description = "Import Inventory"
|
||||
|
||||
def _default_location(self, cr, uid, ids, context=None):
|
||||
location = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'stock_location_stock')
|
||||
location = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'stock_location_stock', raise_exception=False)
|
||||
if not location.exists():
|
||||
return False
|
||||
try:
|
||||
|
|
|
@ -22,11 +22,8 @@ from openerp.addons.website.models import website
|
|||
from openerp.addons.web import http
|
||||
from openerp.addons.web.http import request, LazyResponse
|
||||
|
||||
from ..utils import slugify
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
NOPE = object()
|
||||
# Completely arbitrary limits
|
||||
MAX_IMAGE_WIDTH, MAX_IMAGE_HEIGHT = IMAGE_LIMITS = (1024, 768)
|
||||
|
||||
|
@ -51,20 +48,10 @@ class Website(openerp.addons.web.controllers.main.Home):
|
|||
return response
|
||||
|
||||
@http.route('/pagenew/<path:path>', type='http', auth="user", website=True)
|
||||
def pagenew(self, path, noredirect=NOPE):
|
||||
web = request.registry['website']
|
||||
try:
|
||||
path = web.new_page(request.cr, request.uid, path, context=request.context)
|
||||
except psycopg2.IntegrityError:
|
||||
logger.exception('Unable to create ir_model_data for page %s', path)
|
||||
response = request.website.render('website.creation_failed', {
|
||||
'page': path,
|
||||
'path': '/page/' + request.website.page_for_name(name=path)
|
||||
})
|
||||
response.status_code = 409
|
||||
return response
|
||||
url = "/page/" + path
|
||||
if noredirect is not NOPE:
|
||||
def pagenew(self, path, noredirect=False):
|
||||
xml_id = request.registry['website'].new_page(request.cr, request.uid, path, context=request.context)
|
||||
url = "/page/" + xml_id
|
||||
if noredirect:
|
||||
return werkzeug.wrappers.Response(url, mimetype='text/plain')
|
||||
return werkzeug.utils.redirect(url)
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import fnmatch
|
||||
import inspect
|
||||
import itertools
|
||||
import logging
|
||||
import math
|
||||
import itertools
|
||||
import re
|
||||
import urllib
|
||||
import urlparse
|
||||
|
||||
|
@ -11,13 +12,16 @@ import simplejson
|
|||
import werkzeug
|
||||
import werkzeug.exceptions
|
||||
import werkzeug.wrappers
|
||||
# optional python-slugify import (https://github.com/un33k/python-slugify)
|
||||
try:
|
||||
import slugify as slugify_lib
|
||||
except ImportError:
|
||||
slugify_lib = None
|
||||
|
||||
import openerp
|
||||
from openerp.osv import orm, osv, fields
|
||||
from openerp.tools.safe_eval import safe_eval
|
||||
|
||||
from openerp.addons.web.http import request, LazyResponse
|
||||
from ..utils import slugify
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -49,6 +53,13 @@ def url_for(path_or_uri, lang=None, keep_query=None):
|
|||
|
||||
return location
|
||||
|
||||
def slugify(s, max_length=None):
|
||||
if slugify_lib:
|
||||
return slugify_lib.slugify(s, max_length)
|
||||
spaceless = re.sub(r'\s+', '-', s)
|
||||
specialless = re.sub(r'[^-_A-Za-z0-9]', '', spaceless)
|
||||
return specialless[:max_length]
|
||||
|
||||
def slug(value):
|
||||
if isinstance(value, orm.browse_record):
|
||||
# [(id, name)] = value.name_get()
|
||||
|
@ -117,37 +128,36 @@ class website(osv.osv):
|
|||
return super(website, self).write(cr, uid, ids, vals, context)
|
||||
|
||||
def new_page(self, cr, uid, name, template='website.default_page', ispage=True, context=None):
|
||||
context=context or {}
|
||||
# completely arbitrary max_length
|
||||
idname = slugify(name, max_length=50)
|
||||
|
||||
context = context or {}
|
||||
imd = self.pool.get('ir.model.data')
|
||||
view = self.pool.get('ir.ui.view')
|
||||
template_module, template_name = template.split('.')
|
||||
|
||||
module, tmp_page = template.split('.')
|
||||
view_model, view_id = imd.get_object_reference(cr, uid, module, tmp_page)
|
||||
# completely arbitrary max_length
|
||||
page_name = slugify(name, max_length=50)
|
||||
page_xmlid = "%s.%s" % (template_module, page_name)
|
||||
|
||||
cr.execute('SAVEPOINT new_page')
|
||||
try:
|
||||
newview_id = view.copy(cr, uid, view_id, context=context)
|
||||
newview = view.browse(cr, uid, newview_id, context=context)
|
||||
newview.write({
|
||||
'arch': newview.arch.replace(template, "%s.%s" % (module, idname)),
|
||||
'name': name,
|
||||
# existing page
|
||||
imd.get_object_reference(cr, uid, template_module, page_name)
|
||||
except ValueError:
|
||||
# new page
|
||||
_, template_id = imd.get_object_reference(cr, uid, template_module, template_name)
|
||||
page_id = view.copy(cr, uid, template_id, context=context)
|
||||
page = view.browse(cr, uid, page_id, context=context)
|
||||
page.write({
|
||||
'arch': page.arch.replace(template, page_xmlid),
|
||||
'name': page_name,
|
||||
'page': ispage,
|
||||
})
|
||||
imd.create(cr, uid, {
|
||||
'name': idname,
|
||||
'module': module,
|
||||
'name': page_name,
|
||||
'module': template_module,
|
||||
'model': 'ir.ui.view',
|
||||
'res_id': newview_id,
|
||||
'res_id': page_id,
|
||||
'noupdate': True
|
||||
}, context=context)
|
||||
cr.execute('RELEASE SAVEPOINT new_page')
|
||||
return "%s.%s" % (module, idname)
|
||||
except:
|
||||
cr.execute("ROLLBACK TO SAVEPOINT new_page")
|
||||
raise
|
||||
return page_xmlid
|
||||
|
||||
def page_for_name(self, cr, uid, ids, name, module='website', context=None):
|
||||
# whatever
|
||||
|
|
|
@ -1072,7 +1072,7 @@
|
|||
} else {
|
||||
// Create the page, get the URL back
|
||||
done = $.get(_.str.sprintf(
|
||||
'/pagenew/%s?noredirect', encodeURI(data.id)))
|
||||
'/pagenew/%s?noredirect=1', encodeURI(data.id)))
|
||||
.then(function (response) {
|
||||
self.make_link(response, false, data.id);
|
||||
});
|
||||
|
|
|
@ -3,21 +3,28 @@
|
|||
|
||||
var website = openerp.website;
|
||||
website.snippet = {};
|
||||
website.snippet.readyAnimation = [];
|
||||
|
||||
website.snippet.start_animation = function () {
|
||||
$("[data-snippet-id]").each(function() {
|
||||
var $snipped_id = $(this);
|
||||
if ( !$snipped_id.parents("#oe_snippets").length &&
|
||||
!$snipped_id.parent("body").length &&
|
||||
!$snipped_id.data("snippet-view") &&
|
||||
website.snippet.animationRegistry[$snipped_id.data("snippet-id")]) {
|
||||
var snippet = new website.snippet.animationRegistry[$snipped_id.data("snippet-id")]($snipped_id);
|
||||
$snipped_id.data("snippet-view", snippet);
|
||||
for (var k in website.snippet.animationRegistry) {
|
||||
var Animation = website.snippet.animationRegistry[k];
|
||||
var selector = "[data-snippet-id='"+k+"']";
|
||||
if (Animation.prototype.selector) {
|
||||
selector += ", " + Animation.prototype.selector;
|
||||
}
|
||||
});
|
||||
$(selector).each(function() {
|
||||
var $snipped_id = $(this);
|
||||
if ( !$snipped_id.parents("#oe_snippets").length &&
|
||||
!$snipped_id.parent("body").length &&
|
||||
!$snipped_id.data("snippet-view")) {
|
||||
website.snippet.readyAnimation.push($snipped_id);
|
||||
$snipped_id.data("snippet-view", new Animation($snipped_id));
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
website.snippet.stop_animation = function () {
|
||||
$("[data-snippet-id]").each(function() {
|
||||
$(website.snippet.readyAnimation).each(function() {
|
||||
var $snipped_id = $(this);
|
||||
if ($snipped_id.data("snippet-view")) {
|
||||
$snipped_id.data("snippet-view").stop();
|
||||
|
@ -30,6 +37,7 @@
|
|||
|
||||
website.snippet.animationRegistry = {};
|
||||
website.snippet.Animation = openerp.Class.extend({
|
||||
selector: false,
|
||||
$: function () {
|
||||
return this.$el.find.apply(this.$el, arguments);
|
||||
},
|
||||
|
@ -51,14 +59,15 @@
|
|||
},
|
||||
});
|
||||
|
||||
website.snippet.animationRegistry.carousel =
|
||||
website.snippet.animationRegistry.slider = website.snippet.Animation.extend({
|
||||
selector: ".carousel",
|
||||
start: function () {
|
||||
this.$target.carousel({interval: 10000});
|
||||
},
|
||||
});
|
||||
|
||||
website.snippet.animationRegistry.parallax = website.snippet.Animation.extend({
|
||||
parallax: ".parallax",
|
||||
start: function () {
|
||||
var self = this;
|
||||
setTimeout(function () {self.set_values();});
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
|
||||
__all__ = ['slugify']
|
||||
|
||||
try:
|
||||
# use python-slugify (https://github.com/un33k/python-slugify) if available
|
||||
from slugify import slugify
|
||||
except ImportError:
|
||||
def slugify(s, max_length=None):
|
||||
spaceless = re.sub(r'\s+', '-', s)
|
||||
specialless = re.sub(r'[^-_A-Za-z0-9]', '', spaceless)
|
||||
return specialless[:max_length]
|
|
@ -716,42 +716,6 @@ Sitemap: <t t-esc="url_root"/>sitemap.xml
|
|||
</t>
|
||||
</template>
|
||||
|
||||
<template id="creation_failed">
|
||||
<t t-call="website.layout">
|
||||
<div id="wrap">
|
||||
<div class="oe_structure">
|
||||
<div class="container">
|
||||
<h1 class="text-center">
|
||||
The page "<em><t t-esc="page"/></em>"
|
||||
already exists
|
||||
</h1>
|
||||
<h3 class="text-center text-muted">We could not create it.</h3>
|
||||
<ul>
|
||||
<li>
|
||||
You can <a t-href="#{path}">visit the existing page</a>
|
||||
</li>
|
||||
<li>Or you can <a href="#" class="create-new-page">
|
||||
create an other page.</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="application/javascript">
|
||||
$(document.body).on('click', 'a.create-new-page', function (e) {
|
||||
e.preventDefault();
|
||||
openerp.website.prompt({
|
||||
window_title: "New Page",
|
||||
input: "Page Title",
|
||||
}).then(function (val) {
|
||||
if (val) {
|
||||
document.location = '/pagenew/' + encodeURI(val);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</t>
|
||||
</template>
|
||||
|
||||
<template id="contact">
|
||||
<address t-ignore="true" class="mb0">
|
||||
<div t-att-class="'name' not in fields and 'css_non_editable_mode_hidden'"><span t-esc="name"/></div>
|
||||
|
|
Loading…
Reference in New Issue