summaryrefslogtreecommitdiff
path: root/addons/website
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2016-10-19 18:16:14 +0200
committerChristophe Simonis <chs@odoo.com>2016-10-19 18:16:14 +0200
commit938ffb92da1ea898f661aec04745f7630e2f378c (patch)
tree7faeed8433101836cd0239cf6c23629ef1f1289d /addons/website
parent1f9e92dfef325b6727e1bee3de55bff095ec6cf2 (diff)
parent6466aa499fc37bba5f4feeeecac99448ef88e62e (diff)
[MERGE] forward port branch 10.0 up to 6466aa4
Diffstat (limited to 'addons/website')
-rw-r--r--addons/website/controllers/main.py9
-rw-r--r--addons/website/models/ir_ui_view.py30
-rw-r--r--addons/website/static/src/js/website.editor.js17
-rw-r--r--addons/website/static/src/js/website.snippets.animation.js2
-rw-r--r--addons/website/static/src/js/website.snippets.editor.js11
-rw-r--r--addons/website/static/src/less/website.ui.components.less49
-rw-r--r--addons/website/tests/test_views.py21
7 files changed, 68 insertions, 71 deletions
diff --git a/addons/website/controllers/main.py b/addons/website/controllers/main.py
index 0826ac839d7..3a64816a248 100644
--- a/addons/website/controllers/main.py
+++ b/addons/website/controllers/main.py
@@ -262,10 +262,10 @@ class Website(Home):
@http.route('/website/customize_template_get', type='json', auth='user', website=True)
def customize_template_get(self, key, full=False, bundles=False):
- """ Get inherit view's informations of the template ``key``. By default, only
- :returns ``customize_show`` templates (which can be active or not), if
- ``full=True`` returns inherit view's informations of the template ``key``.
- ``bundles=True`` returns also the asset bundles
+ """ Get inherit view's informations of the template ``key``.
+ returns templates info (which can be active or not)
+ ``full=False`` returns only the customize_show template
+ ``bundles=True`` returns also the asset bundles
"""
return request.env["ir.ui.view"].customize_template_get(key, full=full, bundles=bundles)
@@ -370,6 +370,7 @@ class Website(Home):
], type='http', auth="public", website=True)
def actions_server(self, path_or_xml_id_or_id, **post):
ServerActions = request.env['ir.actions.server']
+ action = action_id = None
# find the action_id: either an xml_id, the path, or an ID
if isinstance(path_or_xml_id_or_id, basestring) and '.' in path_or_xml_id_or_id:
diff --git a/addons/website/models/ir_ui_view.py b/addons/website/models/ir_ui_view.py
index acd9256ea52..110ce7e39ee 100644
--- a/addons/website/models/ir_ui_view.py
+++ b/addons/website/models/ir_ui_view.py
@@ -136,25 +136,13 @@ class View(models.Model):
return qcontext
@api.model
- def customize_template_get(self, key, full=False, bundles=False):
- """ Get inherit view's informations of the template ``key``. By default, only
- :returns ``customize_show`` templates (which can be active or not), if
- ``full=True`` returns inherit view's informations of the template ``key``.
- ``bundles=True`` returns also the asset bundles
+ def _customize_template_get_views(self, key, full=False, bundles=False):
+ """ Get inherit view's informations of the template ``key``.
+ returns views (which can be active or not)
+ ``full=False`` returns only the customize_show template
+ ``bundles=True`` returns also the asset bundles
"""
- result = super(View, self).customize_template_get(key, full=full, bundles=bundles)
-
- imd = self.env['ir.model.data']
- view_theme_id = imd.xmlid_to_res_id('website.theme')
-
- result_filtered = []
- for x in result:
- if not full:
- view = self.browse(x['id'])
- if not view.customize_show:
- continue
- if view_theme_id and x['inherit_id'] == view_theme_id:
- continue
- result_filtered.append(x)
-
- return result_filtered
+ views = super(View, self)._customize_template_get_views(key, full=full, bundles=bundles)
+ if full:
+ return views
+ return views.filtered(lambda v: v.customize_show)
diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js
index 5d2d7706560..a110e6eca3e 100644
--- a/addons/website/static/src/js/website.editor.js
+++ b/addons/website/static/src/js/website.editor.js
@@ -74,16 +74,17 @@ website.TopBarCustomize = Widget.extend({
key: this.view_name,
full: false
}).then(function (result) {
+ var current_group = "";
_.each(result, function (item) {
- if (item.header) {
- $menu.append('<li class="dropdown-header">' + item.name + '</li>');
- } else {
- var $li = $('<li/>', {role: 'presentation'})
- .append($('<a/>', {href: '#', 'data-view-id': item.id, role: 'menuitem'})
- .append(qweb.render('web_editor.components.switch', {id: 'switch-' + item.id, label: item.name})));
- $li.find('input').prop('checked', !!item.active);
- $menu.append($li);
+ if (current_group !== item.inherit_id[1]) {
+ current_group = item.inherit_id[1];
+ $menu.append("<li class=\"dropdown-header\">" + current_group + "</li>");
}
+ var $li = $('<li/>', {role: 'presentation'})
+ .append($('<a/>', {href: '#', 'data-view-id': item.id, role: 'menuitem'})
+ .append(qweb.render('web_editor.components.switch', {id: 'switch-' + item.id, label: item.name})));
+ $li.find('input').prop('checked', !!item.active);
+ $menu.append($li);
});
});
},
diff --git a/addons/website/static/src/js/website.snippets.animation.js b/addons/website/static/src/js/website.snippets.animation.js
index 5d55a25bdb0..572e3a0f0ef 100644
--- a/addons/website/static/src/js/website.snippets.animation.js
+++ b/addons/website/static/src/js/website.snippets.animation.js
@@ -122,7 +122,7 @@ animation.registry.share = animation.Class.extend({
animation.registry.media_video = animation.Class.extend({
selector: ".media_iframe_video",
start: function () {
- if (!this.$target.has('.media_iframe_video_size').length) {
+ if (!this.$target.has('> iframe').length) {
var editor = '<div class="css_editable_mode_display">&nbsp;</div>';
var size = '<div class="media_iframe_video_size">&nbsp;</div>';
this.$target.html(editor+size+'<iframe src="'+_.escape(this.$target.data("src"))+'" frameborder="0" allowfullscreen="allowfullscreen"></iframe>');
diff --git a/addons/website/static/src/js/website.snippets.editor.js b/addons/website/static/src/js/website.snippets.editor.js
index cfd0b561778..4fbb79dd89e 100644
--- a/addons/website/static/src/js/website.snippets.editor.js
+++ b/addons/website/static/src/js/website.snippets.editor.js
@@ -311,8 +311,10 @@ options.registry.parallax = options.Class.extend({
this.$target.data("snippet-view", new animation.registry.parallax(this.$target));
}
this.scroll();
- this.buildingBlock.$el.on("snippet-dropped snippet-activated", this._refresh.bind(this));
- this.$target.on('snippet-option-change snippet-option-preview', this._refresh.bind(this));
+
+ this._refresh_callback = this._refresh.bind(this);
+ this.buildingBlock.$el.on("snippet-dropped snippet-activated", this._refresh_callback);
+ this.$target.on('snippet-option-change snippet-option-preview', this._refresh_callback);
},
scroll: function (type, value) {
this.$target.attr("data-scroll-background-ratio", value);
@@ -330,6 +332,11 @@ options.registry.parallax = options.Class.extend({
this._super.apply(this, arguments);
this._refresh();
},
+ on_remove: function () {
+ this._super.apply(this, arguments);
+ this.$target.off("snippet-option-change snippet-option-preview", this._refresh_callback);
+ this.buildingBlock.$el.off("snippet-dropped snippet-activated", this._refresh_callback);
+ },
});
options.registry.ul = options.Class.extend({
diff --git a/addons/website/static/src/less/website.ui.components.less b/addons/website/static/src/less/website.ui.components.less
index e1230d2b358..5c2aa821e13 100644
--- a/addons/website/static/src/less/website.ui.components.less
+++ b/addons/website/static/src/less/website.ui.components.less
@@ -1,52 +1,25 @@
// MODALS
body .modal {
- a {
- &:focus, &:active, &:focus:active {
- outline: none!important;
- }
- }
&.o_website_modal {
- font-family: @o-we-font-family;
-
- h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
- font-family: @o-we-font-family;
- }
+ .o-w-preserve-base();
+ .o-w-preserve-headings();
+ .o-w-preserve-forms();
+ .o-w-preserve-links();
+ .o-w-preserve-btn();
+ .o-w-preserve-wells();
+ .o-w-preserve-modals();
.modal-content {
- border-radius: 0;
- color: initial!important;
- background-color: @o-we-color-paper!important;
.modal-header .o_subtitle {
margin-left: 10px;
}
.modal-body {
- color: inherit!important;
- background-color: transparent!important;
.o_modal_header {
.o-webclient-padding(@top: 10px, @bottom: 10px);
.clearfix();
}
}
- .modal-footer {
- text-align: left;
-
- .btn {
- border-radius: 0;
-
- &.btn-primary {
- .button-variant(white, @odoo-brand-optional, @odoo-brand-optional);
- text-transform: uppercase;
- }
- &.btn-default {
- .button-variant(@odoo-brand-optional, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0));
- text-transform: uppercase;
- }
- &.btn-link {
- .button-variant(@odoo-brand-optional, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0));
- }
- }
- }
}
@media (min-width: @screen-sm-min) {
@@ -89,7 +62,6 @@ body .modal {
.modal-content {
background-color: black!important;
- color: lightgray!important;
border: 3px outset gray;
border-radius: 20px;
@@ -99,6 +71,7 @@ body .modal {
font-family: @o-we-font-family;
h4 {
+ color: lightgray;
font-family:inherit;
font-weight: normal;
@@ -109,6 +82,8 @@ body .modal {
}
.modal-body {
+ background-color: inherit!important;
+ border-radius: 20px;
padding: 15px;
@mobile-preview-width: 320px;
@@ -324,6 +299,10 @@ body .modal {
// ACE EDITOR
.o_ace_view_editor {
+ .o-w-preserve-base();
+ .o-w-preserve-btn();
+ .o-w-preserve-forms();
+
.o-position-absolute(@odoo-navbar-height, 0, 0);
position: fixed;
z-index: 1001;
diff --git a/addons/website/tests/test_views.py b/addons/website/tests/test_views.py
index 5199b8b9f46..1d963c68026 100644
--- a/addons/website/tests/test_views.py
+++ b/addons/website/tests/test_views.py
@@ -139,6 +139,24 @@ class TestViewSaving(common.TransactionCase):
Company = self.env['res.company']
View = self.env['ir.ui.view']
+ # create a view with an xmlid, like the file import would
+ with self.env.norecompute():
+ self.view_id = View.create(self.cr, self.uid, {
+ 'name': "Test View",
+ 'type': 'qweb',
+ 'arch': ET.tostring(self.arch, encoding='utf-8').decode('utf-8')
+ })
+ imd = self.env['ir.model.data'].create({
+ 'module': 'website',
+ 'name': 'test_view',
+ 'model': 'ir.ui.view',
+ 'res_id': self.view_id,
+ })
+
+ # the xml_id of the view should not be flagged as 'noupdate'
+ self.assertEqual(View.browse(self.cr, self.uid, self.view_id).model_data_id, imd)
+ self.assertFalse(imd.noupdate)
+
replacement = ET.tostring(h.DIV(
h.H3("Column 2"),
h.UL(
@@ -149,6 +167,9 @@ class TestViewSaving(common.TransactionCase):
), encoding='utf-8')
self.view_id.save(value=replacement, xpath='/div/div[2]')
+ # the xml_id of the view should be flagged as 'noupdate'
+ self.assertTrue(imd.noupdate)
+
company = Company.browse(1)
self.assertEqual(company.name, "Acme Corporation")
self.assertEqual(company.phone, "+12 3456789")