diff options
| author | bth-openerp <bth@tinyerp.com> | 2013-10-23 18:38:55 +0530 |
|---|---|---|
| committer | bth-openerp <bth@tinyerp.com> | 2013-10-23 18:38:55 +0530 |
| commit | 9efb55b0beb4e3c1bd2e4d6d0718b75d0cb9836d (patch) | |
| tree | f83ba56de1ffe854ee90755eab6c254f5ae202f0 | |
| parent | c8d1d72a0b927047b3bc83b302c58051b087c13b (diff) | |
| parent | 7dd1934585ed85b925def0a686df04aa3990c5f5 (diff) | |
[MERGE]Merge trunk-website-al.
bzr revid: bth@tinyerp.com-20131023130855-6rt6rip6x1h04xc5
18 files changed, 241 insertions, 204 deletions
diff --git a/addons/website/models/ir_ui_view.py b/addons/website/models/ir_ui_view.py index 955ca4f758b..c85245bb188 100644 --- a/addons/website/models/ir_ui_view.py +++ b/addons/website/models/ir_ui_view.py @@ -1,9 +1,10 @@ # -*- coding: utf-8 -*- +from urlparse import urlparse from lxml import etree, html -from openerp.osv import osv, fields -from urlparse import urlparse +from openerp.osv import osv, fields +from openerp.addons.base import ir class view(osv.osv): _inherit = "ir.ui.view" @@ -83,13 +84,20 @@ class view(osv.osv): return out def replace_arch_section(self, cr, uid, view_id, section_xpath, replacement, context=None): - arch = replacement - if section_xpath: - previous_arch = etree.fromstring(self.browse(cr, uid, view_id, context=context).arch.encode('utf-8')) + # remove branding from replacement section + for att in ir.ir_ui_view.MOVABLE_BRANDING: + replacement.attrib.pop(att, None) + + if not section_xpath: + # replace all of the arch, not just a fragment + arch = replacement + else: + arch = etree.fromstring(self.browse(cr, uid, view_id, context=context).arch.encode('utf-8')) # ensure there's only one match - [previous_section] = previous_arch.xpath(section_xpath) + [previous_section] = arch.xpath(section_xpath) + previous_section.getparent().replace(previous_section, replacement) - arch = previous_arch + return arch def _normalize_urls(self, element): @@ -98,7 +106,7 @@ class view(osv.osv): attr = 'action' if 'action' in element.attrib else None elif element.tag in ['a', 'link']: attr = 'href' if 'href' in element.attrib else None - elif element.tag in ['frame', 'iframe', 'img', 'input', 'script']: + elif element.tag in ['frame', 'iframe', 'script']: attr = 'src' if 'src' in element.attrib else None if attr: value = element.attrib[attr] diff --git a/addons/website/models/website.py b/addons/website/models/website.py index c79ada6e9e4..b6379bcbb79 100644 --- a/addons/website/models/website.py +++ b/addons/website/models/website.py @@ -386,6 +386,17 @@ class base_language_install(osv.osv): 'website_ids': fields.many2many('website', string='Websites to translate'), } + def default_get(self, cr, uid, fields, context=None): + if context is None: + context = {} + defaults = super(base_language_install, self).default_get(cr, uid, fields, context) + website_id = context.get('params', {}).get('website_id') + if website_id: + if 'website_ids' not in defaults: + defaults['website_ids'] = [] + defaults['website_ids'].append(website_id) + return defaults + def lang_install(self, cr, uid, ids, context=None): if context is None: context = {} diff --git a/addons/website/static/lib/ckeditor/core/dom/range.js b/addons/website/static/lib/ckeditor/core/dom/range.js index d567a50ad43..9a330fc8a70 100644 --- a/addons/website/static/lib/ckeditor/core/dom/range.js +++ b/addons/website/static/lib/ckeditor/core/dom/range.js @@ -1360,7 +1360,7 @@ CKEDITOR.dom.range = function( root ) { * * {@link CKEDITOR#SHRINK_TEXT} - Shrink the range boudaries to anchor by the side of enclosed text * node, range remains if there's no text nodes on boundaries at all. * - * @param {Boolean} selectContents Whether result range anchors at the inner OR outer boundary of the node. + * @param {Boolean} [selectContents] Whether result range anchors at the inner OR outer boundary of the node. */ shrink: function( mode, selectContents, shrinkOnBlockBoundary ) { // Unable to shrink a collapsed range. diff --git a/addons/website/static/lib/ckeditor/core/selection.js b/addons/website/static/lib/ckeditor/core/selection.js index e888c3d557c..f3e47c9debb 100644 --- a/addons/website/static/lib/ckeditor/core/selection.js +++ b/addons/website/static/lib/ckeditor/core/selection.js @@ -798,7 +798,7 @@ * * @method * @member CKEDITOR.editor - * @param {Boolean} forceRealSelection Return real selection, instead of saved or fake one. + * @param {Boolean} [forceRealSelection] Return real selection, instead of saved or fake one. * @returns {CKEDITOR.dom.selection} A selection object or null if not available for the moment. */ CKEDITOR.editor.prototype.getSelection = function( forceRealSelection ) { diff --git a/addons/website/static/src/css/editor.css b/addons/website/static/src/css/editor.css index a3151d14855..26032aaf7ce 100644 --- a/addons/website/static/src/css/editor.css +++ b/addons/website/static/src/css/editor.css @@ -112,6 +112,11 @@ table.editorbar-panel td.selected { background-color: #b1c9d9; } +.oe_translate_or { + color: white; + padding: 0 0.2em; +} + .oe_translate_examples li { margin: 10px; padding: 4px; diff --git a/addons/website/static/src/css/editor.sass b/addons/website/static/src/css/editor.sass index dcfa88b89e7..e4ef24dad70 100644 --- a/addons/website/static/src/css/editor.sass +++ b/addons/website/static/src/css/editor.sass @@ -106,6 +106,9 @@ table.editorbar-panel background-color: #b1c9d9 // ---- TRANSLATIONS ---- {{{ +.oe_translate_or + color: white + padding: 0 0.2em .oe_translate_examples li margin: 10px padding: 4px diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index c1f05d9b661..2249de2a24d 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -56,7 +56,7 @@ //noinspection JSValidateTypes editor.addCommand('link', { - exec: function (editor, data) { + exec: function (editor) { link_dialog(editor); return true; }, @@ -65,7 +65,7 @@ }); //noinspection JSValidateTypes editor.addCommand('image', { - exec: function (editor, data) { + exec: function (editor) { image_dialog(editor); return true; }, @@ -177,7 +177,7 @@ var editor = new website.EditorBar(); var $body = $(document.body); editor.prependTo($body).then(function () { - if (location.search.indexOf("unable_editor") >= 0) { + if (location.search.indexOf("enable_editor") >= 0) { editor.edit(); } }); @@ -219,7 +219,7 @@ var view_id = $(event.currentTarget).data('view-id'); openerp.jsonRpc('/website/customize_template_toggle', 'call', { 'view_id': view_id - }).then( function(result) { + }).then( function() { window.location.reload(); }); }); @@ -253,7 +253,6 @@ ); }, edit: function () { - var self = this; this.$buttons.edit.prop('disabled', true); this.$('#website-top-view').hide(); this.$('#website-top-edit').show(); @@ -350,6 +349,7 @@ // The detail attribute indicates the number of times a mouse button has been pressed // we just want the triple click if (e.detail !== 3) { return; } + e.preventDefault(); // Get closest block-level element to the triple-clicked // element (using ckeditor's block list because why not) @@ -422,7 +422,7 @@ return true; }, - start_edition: function ($elements) { + start_edition: function () { var self = this; // create a single editor for the whole page var root = document.getElementById('wrapwrap'); @@ -483,7 +483,7 @@ .filter(function () { var $this = $(this); // keep view sections and fields which are *not* in - // view sections for toplevel editables + // view sections for top-level editables return $this.data('oe-model') === 'ir.ui.view' || !$this.closest('[data-oe-model = "ir.ui.view"]').length; }); @@ -854,7 +854,7 @@ this.preview_image(); }, - file_selection: function (e) { + file_selection: function () { this.$('button.filepicker').removeClass('btn-danger btn-success'); var self = this; diff --git a/addons/website/static/src/js/website.js b/addons/website/static/src/js/website.js index 963a0b1664d..682a6175086 100644 --- a/addons/website/static/src/js/website.js +++ b/addons/website/static/src/js/website.js @@ -21,9 +21,6 @@ templates.push(template); }; website.load_templates = function(templates) { - var def = $.Deferred(); - var count = templates.length; - var dones = _(templates).map(function (t) { return new $.Deferred(function (d) { openerp.qweb.add_template(t, function(err) { @@ -39,8 +36,8 @@ }; website.reload = function () { location.hash = "scrollTop=" + window.document.body.scrollTop; - if (location.search.indexOf("unable_editor") > -1) { - window.location.href = window.location.href.replace(/unable_editor(=[^&]*)?/g, ''); + if (location.search.indexOf("enable_editor") > -1) { + window.location.href = window.location.href.replace(/enable_editor(=[^&]*)?/g, ''); } else { window.location.reload(); } @@ -151,7 +148,7 @@ }); }); - $(document).on('click', '.js_publish_management .js_publish_btn', function (e) { + $(document).on('click', '.js_publish_management .js_publish_btn', function () { var $data = $(this).parents(".js_publish_management:first"); var $btn = $data.find('.btn:first'); var publish = $btn.hasClass("btn-success"); diff --git a/addons/website/static/src/js/website.snippets.js b/addons/website/static/src/js/website.snippets.js index ee759e3d153..0b1ab4e13cd 100644 --- a/addons/website/static/src/js/website.snippets.js +++ b/addons/website/static/src/js/website.snippets.js @@ -196,7 +196,7 @@ } self.make_active($target); }); - $("[data-oe-model]").on('click', function (ev) { + $("[data-oe-model]").on('click', function () { if (!snipped_event_flag && self.$active_snipped_id && !self.$active_snipped_id.parents("[data-snippet-id]:first")) { self.make_active(false); } @@ -224,6 +224,7 @@ }, clean_for_save: function () { for (var k in this.snippets) { + if (!this.snippets.hasOwnProperty(k)) { continue; } var editor = $(this.snippets[k]).data("snippet-editor"); if (editor) { editor.clean_for_save(); @@ -342,9 +343,9 @@ }, stop: function(ev, ui){ if (action === 'insert' && ! dropped) { - var el = $('.oe_drop_zone').nearest({x: ui.position.left, y: ui.position.top}).first() - if (el) { - el.after($toInsert) + var $el = $('.oe_drop_zone').nearest({x: ui.position.left, y: ui.position.top}).first(); + if ($el) { + $el.after($toInsert); dropped = true; } } @@ -460,7 +461,7 @@ // count += $zones.length; // $zones.remove(); - $zones = $('.oe_drop_zone > .oe_drop_zone:not(.oe_vertical)').remove(); // no recusrive zones + $zones = $('.oe_drop_zone > .oe_drop_zone:not(.oe_vertical)').remove(); // no recursive zones count += $zones.length; $zones.remove(); } while (count > 0); @@ -471,14 +472,13 @@ var zone = $(this); var prev = zone.prev(); var next = zone.next(); - var float_prev = zone.prev().css('float') || 'none'; - var float_next = zone.next().css('float') || 'none'; - var disp_prev = zone.prev().css('display') || null; - var disp_next = zone.next().css('display') || null; + var float_prev = prev.css('float') || 'none'; + var float_next = next.css('float') || 'none'; + var disp_prev = prev.css('display') || null; + var disp_next = next.css('display') || null; if( (float_prev === 'left' || float_prev === 'right') && (float_next === 'left' || float_next === 'right') ){ zone.remove(); - return; }else if( !( disp_prev === null || disp_next === null || disp_prev === 'block' @@ -689,7 +689,7 @@ var self = this; var $styles = this.$overlay.find('.oe_options'); var $ul = $styles.find('ul:first'); - _.each(this.parent.style_templates, function (val, key) { + _.each(this.parent.style_templates, function (val) { if (!self.parent.dom_filter(val.selector).is(self.$target)) { return; } @@ -757,7 +757,7 @@ /* * build_snippet - * This method is called just after that a thumbnail is drag and droped into a drop zone + * This method is called just after that a thumbnail is drag and dropped into a drop zone * (after the insertion of this.$body, if this.$body exists) */ build_snippet: function ($target) { @@ -771,7 +771,7 @@ }, /* onFocus - * This method is called when the user click outide the snippet in the dom, after a focus + * This method is called when the user click outside the snippet in the dom, after a focus */ onBlur : function () { this.$overlay.removeClass('oe_active'); @@ -790,7 +790,7 @@ var $ul = this.$editor.find(ul_options); var bg_value = (typeof bg === 'string' ? this.$target.find(bg) : $(bg)).css("background-image").replace(/url\(['"]*|['"]*\)/g, ""); - // bind envent on options + // bind event on options var $li = $ul.find("li"); $li.on('click', function (event) { if ($(this).data("value")) { @@ -893,7 +893,8 @@ var regClass = new RegExp("\\s*" + resize[0][begin].replace(/[-]*[0-9]+/, '[-]*[0-9]+'), 'g'); var cursor = $handle.css("cursor")+'-important'; - $("body").addClass(cursor); + var $body = $(document.body); + $body.addClass(cursor); var body_mousemove = function (event){ event.preventDefault(); @@ -920,15 +921,15 @@ self.parent.cover_target(self.$overlay, self.$target); } }; - $('body').mousemove(body_mousemove); var body_mouseup = function(){ - $('body').unbind('mousemove', body_mousemove); - $('body').unbind('mouseup', body_mouseup); - $("body").removeClass(cursor); + $body.unbind('mousemove', body_mousemove); + $body.unbind('mouseup', body_mouseup); + $body.removeClass(cursor); self.parent.editor_busy = false; }; - $('body').mouseup(body_mouseup); + $body.mousemove(body_mousemove); + $body.mouseup(body_mouseup); }); }, getSize: function () { @@ -998,7 +999,7 @@ if (compass !== 'w') return; - // don't change the rigth border position when we change the offset (replace col size) + // don't change the right border position when we change the offset (replace col size) var beginCol = Number(beginClass.match(/col-md-([0-9]+)|$/)[1] || 0); var beginOffset = Number(beginClass.match(/col-md-offset-([0-9-]+)|$/)[1] || beginClass.match(/col-lg-offset-([0-9-]+)|$/)[1] || 0); var offset = Number(this.grid.w[0][current].match(/col-md-offset-([0-9-]+)|$/)[1] || 0); @@ -1128,7 +1129,6 @@ var style = false; var $el = this.$inner.find('.item.active'); var $ul = this.$editor.find('ul[name="carousel-style"]'); - var $li = $ul.find("li"); if ($el.hasClass('text_only')) style = 'text_only'; @@ -1160,7 +1160,6 @@ }); }, change_size: function () { - var self = this; var $el = this.$target; var size = 'oe_big'; @@ -1197,7 +1196,6 @@ this.change_size(); }, scroll: function(){ - var self = this; var $ul = this.$editor.find('ul[name="parallax-scroll"]'); var $li = $ul.find("li"); var $parallax = this.$target.find('.parallax'); @@ -1207,7 +1205,7 @@ $li.on('click', function (event) { $li.removeClass("active"); $(this).addClass("active"); - var speed = $(this).data('value') + var speed = $(this).data('value'); $parallax.attr('data-stellar-background-ratio', speed); }); diff --git a/addons/website/static/src/js/website.tour.basic.js b/addons/website/static/src/js/website.tour.basic.js index 82ad4790c25..876d2a7b5b9 100644 --- a/addons/website/static/src/js/website.tour.basic.js +++ b/addons/website/static/src/js/website.tour.basic.js @@ -10,6 +10,7 @@ name: "Insert a banner", init: function (editor) { var self = this; + var $body = $(document.body); self.steps = [ { stepId: 'welcome', @@ -56,15 +57,16 @@ onShow: function () { function beginDrag () { $('.popover.tour').remove(); - $('body').off('mousedown', beginDrag); function goToNextStep () { $('#oe_snippets').hide(); self.movetoStep('edit-title'); - $('body').off('mouseup', goToNextStep); + $body.off('mouseup', goToNextStep); } - $('body').on('mouseup', goToNextStep); + $body.off('mousedown', beginDrag); + $body.on('mouseup', goToNextStep); } - $('body').on('mousedown', beginDrag); + + $body.on('mousedown', beginDrag); }, }, { @@ -121,7 +123,7 @@ title: "Help is always available", content: "But you can always click here if you want more tutorials.", template: render('website.tour_popover', { end: "Close" }), - }, + } ]; return this._super(); }, @@ -158,4 +160,4 @@ }, }); -}());
\ No newline at end of file +}()); diff --git a/addons/website/static/src/js/website.translator.js b/addons/website/static/src/js/website.translator.js index fddb5ef7b51..7e237598530 100644 --- a/addons/website/static/src/js/website.translator.js +++ b/addons/website/static/src/js/website.translator.js @@ -6,11 +6,16 @@ var nodialog = 'website_translator_nodialog'; website.EditorBar.include({ + events: _.extend({}, website.EditorBar.prototype.events, { + 'click a[data-action=edit_master]': 'edit_master', + }), start: function () { var self = this; this.initial_content = {}; return this._super.apply(this, arguments).then(function () { - self.$('button[data-action=edit]').text("Translate"); + self.$('button[data-action=edit]') + .text("Translate") + .after(openerp.qweb.render('website.TranslatorAdditionalButtons')); self.$('[data-action=snippet]').hide(); self.$('#customize-menu-button').hide(); }); @@ -24,7 +29,7 @@ dialog.on('activate', this, function () { localStorage[nodialog] = dialog.$('input[name=do_not_show]').prop('checked') || ''; dialog.$el.modal('hide'); - this.translate().then(function () { + self.translate().then(function () { mysuper.call(self); }); }); @@ -34,6 +39,14 @@ }); } }, + edit_master: function (ev) { + ev.preventDefault(); + var link = $('.js_language_selector a[data-default-lang]')[0]; + if (link) { + link.search += (link.search ? '&' : '?') + 'enable_editor=1'; + window.location = link.attributes.href.value; + } + }, translate: function () { var self = this; this.translations = null; @@ -44,7 +57,7 @@ self.translations = translations; self.processTranslatableNodes(); // Disable non translatable t-fields - $('[data-oe-type][data-oe-translate=0]').removeAttr('data-oe-type'); + $('[data-oe-type][data-oe-translate="0"]').removeAttr('data-oe-type'); }); }, processTranslatableNodes: function () { @@ -143,7 +156,6 @@ if (node.attributes['data-oe-translate'].value == '1') { node.className += ' oe_translatable_field'; } - return; } else if (node.childNodes.length === 1 && this.isTextNode(node.childNodes[0]) && !node.getAttribute('data-oe-model')) { @@ -175,7 +187,7 @@ $(root).click(function (ev) { ev.preventDefault(); }); - return $('[data-oe-translate=1]'); + return $('[data-oe-translate="1"]'); } }); diff --git a/addons/website/static/src/xml/website.translator.xml b/addons/website/static/src/xml/website.translator.xml index f35cf583da9..dac074688d8 100644 --- a/addons/website/static/src/xml/website.translator.xml +++ b/addons/website/static/src/xml/website.translator.xml @@ -1,5 +1,9 @@ <?xml version="1.0" encoding="utf-8"?> <templates id="template" xml:space="preserve"> +<t t-name="website.TranslatorAdditionalButtons"> + <strong class="oe_translate_or">or</strong> + <a class="btn btn-default" data-action="edit_master" href="#">Edit Master</a> +</t> <t t-name="website.TranslatorDialog"> <div class="modal fade oe_website_translator" tabindex="-1" role="dialog"> <div class="modal-dialog"> diff --git a/addons/website/views/website_templates.xml b/addons/website/views/website_templates.xml index 19ff01ba997..8862e17a374 100644 --- a/addons/website/views/website_templates.xml +++ b/addons/website/views/website_templates.xml @@ -103,15 +103,16 @@ <li t-if="request.multilang and (len(website.language_ids) > 1 or editable)" class="dropdown"> <!-- TODO: use flags for language selection --> - <a class="dropdown-toggle" data-toggle="dropdown" href="#"> - <t t-esc="lang_selected[0]['name']"/> <span class="caret"></span> + <a class="dropdown-toggle js_language_selected" data-toggle="dropdown" href="#"> + <t t-esc="lang_selected[0]['name'].split('/').pop()"/> <span class="caret"></span> </a> - <ul class="dropdown-menu" role="menu"> + <ul class="dropdown-menu js_language_selector" role="menu"> <li t-foreach="website.language_ids" t-as="lg"> - <a t-att-href="url_for('', lang=lg.code)" role="menuitem"> + <a t-att-href="url_for('', lang=lg.code)" role="menuitem" + t-att-data-default-lang="editable and 'true' if lg.code == website.default_lang_id.code else None"> <strong t-att-class="'icon-circle' if lg.code == lang else 'icon-circle-blank'"></strong> - <t t-esc="lg.name"/> + <t t-esc="lg.name.split('/').pop()"/> </a> </li> <li t-if="editable" class="divider"/> @@ -120,7 +121,7 @@ <t t-if="request.httprequest.query_string"> <t t-set="url_return" t-value="url_return + '?' + request.httprequest.query_string"/> </t> - <a t-attf-href="/web#action=base.action_view_base_language_install&url_return=#{url_return}"> + <a t-attf-href="/web#action=base.action_view_base_language_install&website_id=#{website.id}&url_return=#{url_return}"> Add a language... </a> </li> diff --git a/addons/website_blog/controllers/main.py b/addons/website_blog/controllers/main.py index 81b0610cb11..34a117505a5 100644 --- a/addons/website_blog/controllers/main.py +++ b/addons/website_blog/controllers/main.py @@ -57,7 +57,7 @@ class WebsiteBlog(http.Controller): post pager. :param dict post: kwargs, may contain - - 'unable_editor': editor control + - 'enable_editor': editor control :return dict values: values for the templates, containing @@ -147,7 +147,7 @@ class WebsiteBlog(http.Controller): 'blog_posts': blog_posts, 'pager': pager, 'nav_list': nav, - 'unable_editor': post.get('unable_editor') + 'enable_editor': post.get('enable_editor') } if blog_post: @@ -196,7 +196,7 @@ class WebsiteBlog(http.Controller): context=dict(context, mail_create_nosubcribe=True)) request.session.body = False - return werkzeug.utils.redirect("/blog/%s/?unable_editor=1" % (blog_post_id)) + return werkzeug.utils.redirect("/blog/%s/?enable_editor=1" % (blog_post_id)) @website.route(['/blog/<int:category_id>/new'], type='http', auth="public") def blog_post_create(self, category_id=None, **post): @@ -209,11 +209,11 @@ class WebsiteBlog(http.Controller): 'content': '', 'website_published': False, }, context=create_context) - return werkzeug.utils.redirect("/blog/%s/?unable_editor=1" % (new_blog_post_id)) + return werkzeug.utils.redirect("/blog/%s/?enable_editor=1" % (new_blog_post_id)) @website.route(['/blog/<int:blog_post_id>/duplicate'], type='http', auth="public") def blog_post_copy(self, blog_post_id=None, **post): cr, uid, context = request.cr, request.uid, request.context create_context = dict(context, mail_create_nosubscribe=True) new_blog_post_id = request.registry['blog.post'].copy(cr, uid, blog_post_id, {}, context=create_context) - return werkzeug.utils.redirect("/blog/%s/?unable_editor=1" % (new_blog_post_id)) + return werkzeug.utils.redirect("/blog/%s/?enable_editor=1" % (new_blog_post_id)) diff --git a/addons/website_blog/static/src/js/website_blog.js b/addons/website_blog/static/src/js/website_blog.js index 511fb9b2822..df9f2ea3081 100644 --- a/addons/website_blog/static/src/js/website_blog.js +++ b/addons/website_blog/static/src/js/website_blog.js @@ -1,17 +1,16 @@ $(document).ready(function () { - $form = $('.js_nav_year a:first').on('click', function (e) { + $('.js_nav_year a:first').on('click', function (e) { e.preventDefault(); $(this).next("ul").toggle(); }); - $form = $('.js_nav_month a:first').on('click', function (e) { + $('.js_nav_month a:first').on('click', function (e) { e.preventDefault(); var $ul = $(this).next("ul"); if (!$ul.find('li').length) { $.post('/blog/nav', {'domain': $(this).data("domain")}, function (result) { - var result = JSON.parse(result); var blog_id = +window.location.pathname.split("/").pop(); - $(result).each(function () { + $(JSON.parse(result)).each(function () { var $a = $('<a href="/blog/' + this.category_id + '/' + this.id + '"/>').text(this.name); var $li = $("<li/>").append($a); if (blog_id == this.id) @@ -27,7 +26,7 @@ $(document).ready(function () { } }); - $form = $('.js_website_blog form#comment'); + var $form = $('.js_website_blog form#comment'); $form.submit(function (e) { e.preventDefault(); var error = $form.find("textarea").val().length < 3; @@ -39,4 +38,4 @@ $(document).ready(function () { }); } }); -});
\ No newline at end of file +}); diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index 8756b6f6722..8de0a0bb578 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -28,7 +28,7 @@ def get_order(order_id=None): order_value['pricelist_id'] = request.httprequest.session['ecommerce_pricelist'] order_value['partner_id'] = request.registry.get('res.users').browse(request.cr, SUPERUSER_ID, request.uid, context=request.context).partner_id.id order_value.update(order_obj.onchange_partner_id(request.cr, SUPERUSER_ID, [], order_value['partner_id'], context=request.context)['value']) - + # add website_session_id key for access rules if not request.httprequest.session.get('website_session_id'): request.httprequest.session['website_session_id'] = str(uuid.uuid4()) @@ -182,7 +182,7 @@ class Ecommerce(http.Controller): bin_packing[line + copy_y][col + copy_x] = False bin_packing[line + copy_y][col + copy_x] = product_list[index] break - + if not insert: line += 1 else: @@ -281,7 +281,7 @@ class Ecommerce(http.Controller): if post.get("search"): domain += ['|', '|', '|', - ('name', 'ilike', "%%%s%%" % post.get("search")), + ('name', 'ilike', "%%%s%%" % post.get("search")), ('description', 'ilike', "%%%s%%" % post.get("search")), ('website_description', 'ilike', "%%%s%%" % post.get("search")), ('product_variant_ids.public_categ_id.name', 'ilike', "%%%s%%" % post.get("search"))] @@ -298,7 +298,7 @@ class Ecommerce(http.Controller): step = 20 product_count = len(product_obj.search(request.cr, request.uid, domain, context=request.context)) - pager = request.website.pager(url="/shop/%s" % post, total=product_count, page=page, step=step, scope=7, url_args=post) + pager = request.website.pager(url="/shop/", total=product_count, page=page, step=step, scope=7, url_args=post) request.context['pricelist'] = self.get_pricelist() @@ -354,9 +354,9 @@ class Ecommerce(http.Controller): @website.route(['/shop/add_product/', '/shop/category/<int:cat_id>/add_product/'], type='http', auth="public", multilang=True) def add_product(self, cat_id=0, **post): - product_id = request.registry.get('product.product').create(request.cr, request.uid, + product_id = request.registry.get('product.product').create(request.cr, request.uid, {'name': 'New Product', 'public_categ_id': cat_id}, request.context) - return request.redirect("/shop/product/%s/?unable_editor=1" % product_id) + return request.redirect("/shop/product/%s/?enable_editor=1" % product_id) def get_pricelist(self): if not request.httprequest.session.get('ecommerce_pricelist'): @@ -376,7 +376,7 @@ class Ecommerce(http.Controller): if not pricelist_id: partner_id = request.registry.get('res.users').browse(request.cr, SUPERUSER_ID, request.uid, request.context).partner_id.id pricelist_id = request.registry['sale.order'].onchange_partner_id(request.cr, SUPERUSER_ID, [], partner_id, context=request.context)['value']['pricelist_id'] - + request.httprequest.session['ecommerce_pricelist'] = pricelist_id order = get_current_order() diff --git a/addons/website_sale/static/src/js/website_sale.js b/addons/website_sale/static/src/js/website_sale.js index ab10c04ad9b..5f31d52fccb 100644 --- a/addons/website_sale/static/src/js/website_sale.js +++ b/addons/website_sale/static/src/js/website_sale.js @@ -3,8 +3,8 @@ $(document).ready(function () { $(".oe_website_sale .js_shipping").toggle(); }); - $payment = $(".oe_website_sale .js_payment"); - $("input[name='payment_type']", $payment).click(function (ev) { + var $payment = $(".oe_website_sale .js_payment"); + $payment.find("input[name='payment_type']").click(function (ev) { var payment_id = $(ev.currentTarget).val(); $("div[data-id]", $payment).addClass("hidden"); $("a.btn:last, div[data-id='"+payment_id+"']", $payment).removeClass("hidden"); @@ -114,7 +114,7 @@ $(document).ready(function () { var y = $td.parent().index()+1; openerp.jsonRpc('/shop/change_size/', 'call', {'id': $data.data('id'), 'x': x, 'y': y}) .then(function () { - var search = location.search.replace(/\?|$/, '?unable_editor=1&'); + var search = location.search.replace(/\?|$/, '?enable_editor=1&'); location.href = location.href.replace(/(\?|#).*/, search + location.hash); }); }); diff --git a/addons/website_sale/views/website_sale.xml b/addons/website_sale/views/website_sale.xml index d8e446e79d3..4f2cc38f235 100644 --- a/addons/website_sale/views/website_sale.xml +++ b/addons/website_sale/views/website_sale.xml @@ -60,7 +60,7 @@ </div> <div class="oe_product_image text-center"> <a t-href="/shop/product/#{ product.id }/" t-keep-query="category,search,facettes"> - <img class="img" t-att-src="product.img('image')"/> + <span t-field="product.image" t-field-options='{"widget": "image"}'/> </a> </div> </template> @@ -72,16 +72,15 @@ <link rel='stylesheet' href='/website_sale/static/src/css/website_sale.css'/> <t t-raw="head or ''"/> </t> - <t t-set="additional_title">Our Products</t> + <t t-set="additional_title">Shop</t> <div id="wrap"> <div class="oe_structure"/> <div class="container oe_website_sale"> <div class="row"> - <div class="col-sm-4"> - <h1>Our Products</h1> - </div><div class="col-sm-2 pagination text-center"> + <div class="col-sm-6 pagination" style="padding-left: 15px;"> <a t-if="editable" t-href="/shop/add_product/" class="btn btn-primary btn-default" t-keep-query="category,search,facettes">New Product</a> - </div><div class="col-sm-6"> + </div> + <div class="col-sm-6"> <t t-call="website.pager"> <t t-set="classname">pull-right</t> </t> @@ -170,8 +169,10 @@ </table> </div> </div> - <div class="text-center"> - <t t-call="website.pager" /> + <div> + <t t-call="website.pager"> + <t t-set="classname">pull-right</t> + </t> </div> </div> <div class="oe_structure mb32"/> @@ -356,120 +357,116 @@ <li class="text-muted">Payment<span class="chevron"></span></li> <li class="text-muted">Confirmation<span class="chevron"></span></li> </ul> - <h1 class="mb32">Your Cart</h1> - + <h1 class="mb32">Shopping Cart</h1> <div class="row"> - <div class="col-md-8 oe_mycart"> - <div t-if="not website_sale_order or not website_sale_order.order_line" class="well well-lg"> - Your cart is empty! + <div class="col-md-3 text-muted" id="right_column"> + <h4>Policies</h4> + <ul class="list-unstyled mb32"> + <li>☑ 30-days money-back guarantee</li> + <li>☑ Invoice sent by e-Mail</li> + </ul> + <h4>Secure Payment</h4> + <ul class="list-unstyled mb32"> + <li>☑ 256 bit encryption</li> + <li>☑ Processed by Ogone</li> + </ul> </div> - <table class='table table-striped table-condensed' id="mycart_products" t-if="website_sale_order and website_sale_order.order_line"> - <colgroup> - <col width="80"/> - <col/> - <col width="100"/> - <col width="120"/> - </colgroup> - <thead> - <tr> - <th colspan="2">Product</th> - <th>Price</th> - <th>Quantity</th> - </tr> - </thead> - <tbody> - <tr t-foreach="website_sale_order.order_line" t-as="line"> - <td colspan="2" t-if="not line.product_id.product_tmpl_id"></td> - <td t-if="line.product_id.product_tmpl_id"> - <span t-field="line.product_id.image_small" - t-field-options='{"widget": "image", "class": "img-rounded"}'/> - </td> - <td t-if="line.product_id.product_tmpl_id"> - <div> - <a t-href="/shop/product/#{ line.product_id.product_tmpl_id.id }/"> - <strong t-field="line.product_id.name"/> - </a> - </div> - <div class="text-muted" t-field="line.product_id.description_sale"/> - </td> - <td class="text-center"> - <del class="text-danger" t-if="line.product_id.lst_price > line.price_unit"> - <span t-field="line.product_id.lst_price" t-field-options='{ + <div class="col-md-8 col-md-offset-1 oe_mycart"> + <div t-if="not website_sale_order or not website_sale_order.order_line" class="well well-lg"> + Your cart is empty! + </div> + <table class='table table-striped table-condensed' id="mycart_products" t-if="website_sale_order and website_sale_order.order_line"> + <colgroup> + <col width="80"/> + <col/> + <col width="100"/> + <col width="120"/> + </colgroup> + <thead> + <tr> + <th colspan="2">Product</th> + <th>Price</th> + <th>Quantity</th> + </tr> + </thead> + <tbody> + <tr t-foreach="website_sale_order.order_line" t-as="line"> + <td colspan="2" t-if="not line.product_id.product_tmpl_id"></td> + <td t-if="line.product_id.product_tmpl_id"> + <span t-field="line.product_id.image_small" + t-field-options='{"widget": "image", "class": "img-rounded"}'/> + </td> + <td t-if="line.product_id.product_tmpl_id"> + <div> + <a t-href="/shop/product/#{ line.product_id.product_tmpl_id.id }/"> + <strong t-field="line.product_id.name"/> + </a> + </div> + <div class="text-muted" t-field="line.product_id.description_sale"/> + </td> + <td class="text-center"> + <del class="text-danger" t-if="line.product_id.lst_price > line.price_unit"> + <span t-field="line.product_id.lst_price" t-field-options='{ + "widget": "monetary", + "display_currency": "website.pricelist_id.currency_id" + }'/> + </del> + <span t-field="line.price_unit" t-field-options='{ "widget": "monetary", "display_currency": "website.pricelist_id.currency_id" }'/> - </del> - <span t-field="line.price_unit" t-field-options='{ - "widget": "monetary", - "display_currency": "website.pricelist_id.currency_id" - }'/> - </td> - <td> - <div class="input-group"> - <span class="input-group-addon"> - <a t-href="./remove_cart/?order_line_id=#{ line.id }" t-att-data-id="line.id" class="mb8 js_add_cart_json"> - <span class="icon-minus"/> - </a> - </span> - <input type="text" class="js_quantity form-control" - t-att-data-id="line.id" t-att-value="int(line.product_uom_qty)"/> - <span class="input-group-addon"> - <a t-href="./add_cart/?order_line_id=#{ line.id }" t-att-data-id="line.id" class="mb8 float_left js_add_cart_json"> - <span class="icon-plus"/> - </a> - </span> - </div> - - </td> - </tr> - </tbody> - </table> - <table class='pull-right mb16' id="mycart_total"> - <colgroup> - <col width="100"/> - <col width="120"/> - </colgroup> - <thead> - <tr style="border-top: 1px solid #000"> - <th><h3>Total:</h3></th> - <th class="text-right"><h3> - <span t-field="website_sale_order.amount_total" t-field-options='{ - "widget": "monetary", - "display_currency": "website.pricelist_id.currency_id" - }'/></h3> - </th> - </tr> - <tr class="text-muted"> - <td><abbr title="Taxes may be updated after providing shipping address">Incl. Taxes:</abbr></td> - <td class="text-right"> - <span t-field="website_sale_order.amount_tax" t-field-options='{ - "widget": "monetary", - "display_currency": "website.pricelist_id.currency_id" - }'/> - </td> - </tr> - </thead> - </table> - <div class="clearfix"/> - - <a t-href="/shop" class="btn btn-default"><span class="icon-long-arrow-left"/> Continue Shopping</a> - <a t-if="website_sale_order and website_sale_order.order_line" t-href="/shop/checkout/" class="btn btn-primary pull-right mb32">Process Checkout <span class="icon-long-arrow-right"/></a> - <div class="oe_structure"/> - </div> - <div class="col-md-3 col-md-offset-1 text-muted" id="right_column"> - <h4>Policies</h4> - <ul class="list-unstyled mb32"> - <li>☑ 30-days money-back guarantee</li> - <li>☑ Invoice sent by e-Mail</li> - </ul> - - <h4>Secure Payment</h4> - <ul class="list-unstyled mb32"> - <li>☑ Transation 256bit encrypted</li> - <li>☑ Processed by Ogone</li> - </ul> - - </div> + </td> + <td> + <div class="input-group"> + <span class="input-group-addon"> + <a t-href="./remove_cart/?order_line_id=#{ line.id }" t-att-data-id="line.id" class="mb8 js_add_cart_json"> + <span class="icon-minus"/> + </a> + </span> + <input type="text" class="js_quantity form-control" + t-att-data-id="line.id" t-att-value="int(line.product_uom_qty)"/> + <span class="input-group-addon"> + <a t-href="./add_cart/?order_line_id=#{ line.id }" t-att-data-id="line.id" class="mb8 float_left js_add_cart_json"> + <span class="icon-plus"/> + </a> + </span> + </div> + + </td> + </tr> + </tbody> + </table> + <table class='pull-right mb16' id="mycart_total"> + <colgroup> + <col width="100"/> + <col width="120"/> + </colgroup> + <thead> + <tr style="border-top: 1px solid #000"> + <th><h3>Total:</h3></th> + <th class="text-right"><h3> + <span t-field="website_sale_order.amount_total" t-field-options='{ + "widget": "monetary", + "display_currency": "website.pricelist_id.currency_id" + }'/></h3> + </th> + </tr> + <tr class="text-muted"> + <td><abbr title="Taxes may be updated after providing shipping address">Incl. Taxes:</abbr></td> + <td class="text-right"> + <span t-field="website_sale_order.amount_tax" t-field-options='{ + "widget": "monetary", + "display_currency": "website.pricelist_id.currency_id" + }'/> + </td> + </tr> + </thead> + </table> + <div class="clearfix"/> + <a t-href="/shop" class="btn btn-default"><span class="icon-long-arrow-left"/> Continue Shopping</a> + <a t-if="website_sale_order and website_sale_order.order_line" t-href="/shop/checkout/" class="btn btn-primary pull-right mb32">Process Checkout <span class="icon-long-arrow-right"/></a> + <div class="oe_structure"/> + </div> </div> </div> |
