Skip to content

Commit

Permalink
[MERGE] ir-ui-view split active and show_customize
Browse files Browse the repository at this point in the history
Split the ternary field application in active and show_customize, all four
possible value are now needed for the customize theme popup.
  • Loading branch information
antonylesuisse committed Aug 31, 2014
1 parent 1564a66 commit 2d296cb
Show file tree
Hide file tree
Showing 22 changed files with 120 additions and 134 deletions.
2 changes: 1 addition & 1 deletion addons/report_webkit/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class WebkitXMLImport(original_xml_import):
# The solution is not meant to be long term solution, but at least
# allows chaining of several overrides of the _tag_report method,
# and does not require a copy/paste of the original code.
def _tag_report(self, cr, rec, data_node=None):
def _tag_report(self, cr, rec, data_node=None, mode=None):
report_id = super(WebkitXMLImport, self)._tag_report(cr, rec, data_node)
if rec.get('report_type') == 'webkit':
header = rec.get('webkit_header')
Expand Down
15 changes: 7 additions & 8 deletions addons/website/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,19 +186,18 @@ def theme_change(self, theme_id=False, **kwargs):
request.cr, request.uid, 'website', 'theme')
views = Views.search(request.cr, request.uid, [
('inherit_id', '=', theme_template_id),
('application', '=', 'enabled'),
], context=request.context)
Views.write(request.cr, request.uid, views, {
'application': 'disabled',
}, context=request.context)
'active': False,
}, context=dict(request.context or {}, active_test=True))

if theme_id:
module, xml_id = theme_id.split('.')
_, view_id = imd.get_object_reference(
request.cr, request.uid, module, xml_id)
Views.write(request.cr, request.uid, [view_id], {
'application': 'enabled'
}, context=request.context)
'active': True
}, context=dict(request.context or {}, active_test=True))

return request.render('website.themes', {'theme_changed': True})

Expand Down Expand Up @@ -242,13 +241,13 @@ def customize_template_get(self, xml_id, full=False):
user_groups = set(user.groups_id)

views = request.registry["ir.ui.view"]\
._views_get(request.cr, request.uid, xml_id, context=request.context)
._views_get(request.cr, request.uid, xml_id, context=dict(request.context or {}, active_test=False))
done = set()
result = []
for v in views:
if not user_groups.issuperset(v.groups_id):
continue
if full or (v.application != 'always' and v.inherit_id.id != view_theme_id):
if full or (v.customize_show and v.inherit_id.id != view_theme_id):
if v.inherit_id not in done:
result.append({
'name': v.inherit_id.name,
Expand All @@ -265,7 +264,7 @@ def customize_template_get(self, xml_id, full=False):
'xml_id': v.xml_id,
'inherit_id': v.inherit_id.id,
'header': False,
'active': v.application in ('always', 'enabled'),
'active': v.active,
})
return result

Expand Down
11 changes: 5 additions & 6 deletions addons/website/models/ir_ui_view.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# -*- coding: utf-8 -*-
import copy
import re
import simplejson
import werkzeug

from lxml import etree, html

Expand All @@ -18,9 +15,11 @@ class view(osv.osv):
'website_meta_title': fields.char("Website meta title", size=70, translate=True),
'website_meta_description': fields.text("Website meta description", size=160, translate=True),
'website_meta_keywords': fields.char("Website meta keywords", translate=True),
'customize_show': fields.boolean("Show As Optional Inherit"),
}
_defaults = {
'page': False,
'customize_show': False,
}


Expand Down Expand Up @@ -68,15 +67,14 @@ def _views_get(self, cr, uid, view_id, options=True, context=None, root=True):
extensions = view.inherit_children_ids
if not options:
# only active children
extensions = (v for v in view.inherit_children_ids
if v.application in ('always', 'enabled'))
extensions = (v for v in view.inherit_children_ids if v.active)

# Keep options in a deterministic order regardless of their applicability
for extension in sorted(extensions, key=lambda v: v.id):
for r in self._views_get(
cr, uid, extension,
# only return optional grandchildren if this child is enabled
options=extension.application in ('always', 'enabled'),
options=extension.active,
context=context, root=False):
if r not in result:
result.append(r)
Expand Down Expand Up @@ -214,3 +212,4 @@ def save(self, cr, uid, res_id, value, xpath=None, context=None):
view = self.browse(cr, SUPERUSER_ID, res_id, context=context)
if view.model_data_id:
view.model_data_id.write({'noupdate': True})

24 changes: 12 additions & 12 deletions addons/website/views/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -203,82 +203,82 @@
All Default Themes
-->

<template id="website.theme_amelia" name="Amelia" inherit_id="website.theme" optional="disabled">
<template id="website.theme_amelia" name="Amelia" inherit_id="website.theme" active="False" customize_show="True">
<xpath expr="//link[@id='bootstrap_css']" position="replace">
<link rel='stylesheet' href='/website/static/src/css/bootswatch/amelia.min.css' t-ignore="true"/>
<link rel='stylesheet' href='/website/static/src/css/bootswatch/amelia.fix.css' t-ignore="true"/>
</xpath>
</template>

<template id="website.theme_cerulean" name="Cerulean" inherit_id="website.theme" optional="disabled">
<template id="website.theme_cerulean" name="Cerulean" inherit_id="website.theme" active="False" customize_show="True">
<xpath expr="//link[@id='bootstrap_css']" position="replace">
<link rel='stylesheet' href='/website/static/src/css/bootswatch/cerulean.min.css' t-ignore="true"/>
</xpath>
</template>

<template id="website.theme_cosmo" name="Cosmo" inherit_id="website.theme" optional="disabled">
<template id="website.theme_cosmo" name="Cosmo" inherit_id="website.theme" active="False" customize_show="True">
<xpath expr="//link[@id='bootstrap_css']" position="replace">
<link rel='stylesheet' href='/website/static/src/css/bootswatch/cosmo.min.css' t-ignore="true"/>
<link rel='stylesheet' href='/website/static/src/css/bootswatch/cosmo.fix.css' t-ignore="true"/>
</xpath>
</template>

<template id="website.theme_cyborg" name="Cyborg" inherit_id="website.theme" optional="disabled">
<template id="website.theme_cyborg" name="Cyborg" inherit_id="website.theme" active="False" customize_show="True">
<xpath expr="//link[@id='bootstrap_css']" position="replace">
<link rel='stylesheet' href='/website/static/src/css/bootswatch/cyborg.min.css' t-ignore="true"/>
<link rel='stylesheet' href='/website/static/src/css/bootswatch/cyborg.fix.css' t-ignore="true"/>
</xpath>
</template>

<template id="website.theme_flatly" name="Flatly" inherit_id="website.theme" optional="disabled">
<template id="website.theme_flatly" name="Flatly" inherit_id="website.theme" active="False" customize_show="True">
<xpath expr="//link[@id='bootstrap_css']" position="replace">
<link rel='stylesheet' href='/website/static/src/css/bootswatch/flatly.min.css' t-ignore="true"/>
<link rel='stylesheet' href='/website/static/src/css/bootswatch/flatly.fix.css' t-ignore="true"/>
</xpath>
</template>

<template id="website.theme_journal" name="Journal" inherit_id="website.theme" optional="disabled">
<template id="website.theme_journal" name="Journal" inherit_id="website.theme" active="False" customize_show="True">
<xpath expr="//link[@id='bootstrap_css']" position="replace">
<link rel='stylesheet' href='/website/static/src/css/bootswatch/journal.min.css' t-ignore="true"/>
<link rel='stylesheet' href='/website/static/src/css/bootswatch/journal.fix.css' t-ignore="true"/>
</xpath>
</template>

<template id="website.theme_readable" name="Readable" inherit_id="website.theme" optional="disabled">
<template id="website.theme_readable" name="Readable" inherit_id="website.theme" active="False" customize_show="True">
<xpath expr="//link[@id='bootstrap_css']" position="replace">
<link rel='stylesheet' href='/website/static/src/css/bootswatch/readable.min.css' t-ignore="true"/>
<link rel='stylesheet' href='/website/static/src/css/bootswatch/readable.fix.css' t-ignore="true"/>
</xpath>
</template>

<template id="website.theme_simplex" name="Simplex" inherit_id="website.theme" optional="disabled">
<template id="website.theme_simplex" name="Simplex" inherit_id="website.theme" active="False" customize_show="True">
<xpath expr="//link[@id='bootstrap_css']" position="replace">
<link rel='stylesheet' href='/website/static/src/css/bootswatch/simplex.min.css' t-ignore="true"/>
<link rel='stylesheet' href='/website/static/src/css/bootswatch/simplex.fix.css' t-ignore="true"/>
</xpath>
</template>

<template id="website.theme_slate" name="Slate" inherit_id="website.theme" optional="disabled">
<template id="website.theme_slate" name="Slate" inherit_id="website.theme" active="False" customize_show="True">
<xpath expr="//link[@id='bootstrap_css']" position="replace">
<link rel='stylesheet' href='/website/static/src/css/bootswatch/slate.min.css' t-ignore="true"/>
<link rel='stylesheet' href='/website/static/src/css/bootswatch/slate.fix.css' t-ignore="true"/>
</xpath>
</template>

<template id="website.theme_spacelab" name="Spacelab" inherit_id="website.theme" optional="disabled">
<template id="website.theme_spacelab" name="Spacelab" inherit_id="website.theme" active="False" customize_show="True">
<xpath expr="//link[@id='bootstrap_css']" position="replace">
<link rel='stylesheet' href='/website/static/src/css/bootswatch/spacelab.min.css' t-ignore="true"/>
<link rel='stylesheet' href='/website/static/src/css/bootswatch/spacelab.fix.css' t-ignore="true"/>
</xpath>
</template>

<template id="website.theme_united" name="United" inherit_id="website.theme" optional="disabled">
<template id="website.theme_united" name="United" inherit_id="website.theme" active="False" customize_show="True">
<xpath expr="//link[@id='bootstrap_css']" position="replace">
<link rel='stylesheet' href='/website/static/src/css/bootswatch/united.min.css' t-ignore="true"/>
</xpath>
</template>

<template id="website.theme_yeti" name="Yeti" inherit_id="website.theme" optional="disabled">
<template id="website.theme_yeti" name="Yeti" inherit_id="website.theme" active="False" customize_show="True">
<xpath expr="//link[@id='bootstrap_css']" position="replace">
<link rel='stylesheet' href='/website/static/src/css/bootswatch/yeti.min.css' t-ignore="true"/>
<link rel='stylesheet' href='/website/static/src/css/bootswatch/yeti.fix.css' t-ignore="true"/>
Expand Down
6 changes: 3 additions & 3 deletions addons/website/views/website_templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
</xpath>
</template>

<template id="layout_logo_show" inherit_id="website.layout" optional="enabled" name="Show Logo">
<template id="layout_logo_show" inherit_id="website.layout" customize_show="True" name="Show Logo">
<xpath expr="//header//a[@class='navbar-brand']" position="replace">
<a href="/" class="navbar-brand logo">
<img src="/logo.png"/>
Expand Down Expand Up @@ -230,7 +230,7 @@
</xpath>
</template>

<template id="show_sign_in" optional="enabled" inherit_id="website.layout" name="Show Sign In" groups="base.group_public">
<template id="show_sign_in" customize_show="True" inherit_id="website.layout" name="Show Sign In" groups="base.group_public">
<xpath expr="//ul[@id='top_menu']" position="inside">
<li class="divider"/>
<li>
Expand Down Expand Up @@ -272,7 +272,7 @@
</xpath>
</template>

<template id="footer_default" inherit_id="website.footer_custom" optional="enabled" name="Automatic Footer">
<template id="footer_default" inherit_id="website.footer_custom" customize_show="True" name="Automatic Footer">
<xpath expr="//div[@id='footer']" position="replace">
<div class="container hidden-print">
<div class="row">
Expand Down
24 changes: 12 additions & 12 deletions addons/website_blog/views/website_blog_templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@

<!-- Option: Blog Post List: show tags -->
<template id="opt_blog_post_short_tags" name="Tags"
optional="enabled" inherit_id="website_blog.blog_post_short">
customize_show="True" inherit_id="website_blog.blog_post_short">
<xpath expr="//div[@name='blog_post_data']" position="inside">
<p class="post-meta text-muted text-center" t-if="len(blog_post.tag_ids)">
<span class="fa fa-tags"/>
Expand Down Expand Up @@ -265,7 +265,7 @@

<!-- Options: Blog Post: breadcrumb -->
<template id="blog_breadcrumb" name="Breadcrumb"
inherit_id="website_blog.blog_post_complete" optional="disabled">
inherit_id="website_blog.blog_post_complete" active="False" customize_show="True">
<xpath expr="//div[@id='title']" position="before">
<div class="container">
<div class="row">
Expand All @@ -285,7 +285,7 @@

<!-- Options: Blog Post: user can reply -->
<template id="opt_blog_post_complete_comment" name="Allow blog post comment"
inherit_id="website_blog.blog_post_complete" optional="disabled"
inherit_id="website_blog.blog_post_complete" active="False" customize_show="True"
groups="website_mail.group_comment">
<xpath expr="//ul[@id='comments-list']" position="before">
<section class="mb32 read_width css_editable_mode_hidden">
Expand All @@ -307,7 +307,7 @@

<!-- Options: Blog Post: user can select text for tweet -->
<template id="opt_blog_post_select_to_tweet" name="Select to Tweet"
inherit_id="website_blog.blog_post_complete" optional="disabled">
inherit_id="website_blog.blog_post_complete" active="False" customize_show="True">
<xpath expr="//div[@id='blog_content']" position="attributes">
<attribute name="class">js_tweet mt32</attribute>
</xpath>
Expand All @@ -318,15 +318,15 @@

<!-- Options: Blog Post: user can add Inline Discussion -->
<template id="opt_blog_post_inline_discussion" name="Allow comment in text"
inherit_id="website_blog.blog_post_complete" optional="disabled">
inherit_id="website_blog.blog_post_complete" active="False" customize_show="True">
<xpath expr="//div[@id='blog_content']" position="attributes">
<attribute name="enable_chatter_discuss">True</attribute>
</xpath>
</template>

<!-- Options: Blog Post: show tags -->
<template id="opt_blog_post_complete_tags" name="Tags"
optional="enabled" inherit_id="website_blog.blog_post_complete">
customize_show="True" inherit_id="website_blog.blog_post_complete">
<xpath expr="//p[@name='blog_post_data']" position="after">
<p class="post-meta text-muted text-center" t-if="len(blog_post.tag_ids)">
<span class="fa fa-tags"/>
Expand Down Expand Up @@ -358,7 +358,7 @@
<!-- Option:Right Column for extra info -->

<template id="index_right" name="Right Column"
inherit_id="website_blog.blog_post_short" optional="disabled">
inherit_id="website_blog.blog_post_short" active="False" customize_show="True">
<xpath expr="//div[@id='main_column']" position="attributes">
<attribute name="class">col-sm-8</attribute>
</xpath>
Expand All @@ -369,7 +369,7 @@

<!-- Option:Right Column: tags -->
<template id="opt_blog_rc_tags" name="Tags"
inherit_id="website_blog.index_right" optional="disabled">
inherit_id="website_blog.index_right" active="False" customize_show="True">
<xpath expr="//div[@id='blog_right_column']" position="inside">
<section class="mt32">
<h4>Tags</h4>
Expand All @@ -386,7 +386,7 @@

<!-- Option:Right Column: archives -->
<template id="opt_blog_rc_history" name="Archives"
inherit_id="website_blog.index_right" optional="disabled">
inherit_id="website_blog.index_right" active="False" customize_show="True">
<xpath expr="//div[@id='blog_right_column']" position="inside">
<section class="mt32">
<h4>Archives</h4>
Expand All @@ -403,7 +403,7 @@

<!-- Option:Right Column: about us -->
<template id="opt_blog_rc_about_us" name="About Us" priority="2"
inherit_id="website_blog.index_right" optional="disabled">
inherit_id="website_blog.index_right" active="False" customize_show="True">
<xpath expr="//div[@id='blog_right_column']" position="inside">
<section class="mt32">
<h4>About us</h4>
Expand All @@ -420,7 +420,7 @@

<!-- Option:Right Column: follow us -->
<template id="opt_blog_rc_follow_us" name="Follow us" priority="4"
inherit_id="website_blog.index_right" optional="disabled">
inherit_id="website_blog.index_right" active="False" customize_show="True">
<xpath expr="//div[@id='blog_right_column']" position="inside">
<section class="mt32">
<h4>Follow us<small t-if="blog">: <t t-esc="blog.name"/></small></h4>
Expand All @@ -447,7 +447,7 @@

<!-- Option:Right Column: blogs -->
<template id="opt_blog_rc_blogs" name="Our Blogs" priority="6"
inherit_id="website_blog.index_right" optional="disabled">
inherit_id="website_blog.index_right" active="False" customize_show="True">
<xpath expr="//div[@id='blog_right_column']" position="inside">
<section class="mt32 mb32">
<h4>Our Blogs</h4>
Expand Down
4 changes: 2 additions & 2 deletions addons/website_crm/views/website_crm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<openerp>
<data>

<template id="contactus_form" name="Contact Form" inherit_id="website.contactus" optional="enabled">
<template id="contactus_form" name="Contact Form" inherit_id="website.contactus" customize_show="True">
<xpath expr="//div[@name='mail_button']" position="replace">
<form action="/crm/contactus" method="post" class="form-horizontal mt32" enctype="multipart/form-data">
<t t-foreach="kwargs" t-as="kwarg">
Expand Down Expand Up @@ -47,7 +47,7 @@
</xpath>
</template>

<template id="contactus_form_company_name" name="Company Name" inherit_id="website_crm.contactus_form" optional="enabled">
<template id="contactus_form_company_name" name="Company Name" inherit_id="website_crm.contactus_form" customize_show="True">
<xpath expr="//div[@name='email_from_container']" position="after">
<div t-attf-class="form-group #{error and 'partner_name' in error and 'has-error' or ''}">
<label class="col-md-3 col-sm-4 control-label" for="partner_name">Your Company</label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
</t>
</template>

<template id="ref_country" inherit_id="website_crm_partner_assign.index" optional="enabled" name="Left World Map">
<template id="ref_country" inherit_id="website_crm_partner_assign.index" customize_show="True" name="Left World Map">
<xpath expr="//ul[@id='reseller_countries']" position="after">
<!-- modal for large map -->
<div class="modal fade partner_map_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
Expand Down
4 changes: 2 additions & 2 deletions addons/website_customer/views/website_customer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
</template>

<!-- Option: left column: World Map -->
<template id="opt_country" inherit_id="website_customer.index" optional="enabled" name="Show Map">
<template id="opt_country" inherit_id="website_customer.index" customize_show="True" name="Show Map">
<xpath expr="//div[@id='ref_left_column']" position="inside">
<!-- modal for large map -->
<div class="modal fade customer_map_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
Expand All @@ -90,7 +90,7 @@
</xpath>
</template>

<template id="opt_country_list" inherit_id="website_customer.index" optional="enabled" name="Filter on Countries">
<template id="opt_country_list" inherit_id="website_customer.index" customize_show="True" name="Filter on Countries">
<xpath expr="//div[@id='ref_left_column']" position="inside">
<h3>References by Country</h3>
<ul class="nav nav-pills nav-stacked mt16 mb32">
Expand Down
Loading

0 comments on commit 2d296cb

Please sign in to comment.