Commit ba57396c authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_web&erp5_web_ui_test: do redirect when portal_skin is present

See merge request nexedi/erp5!1502
parents 319388d6 61c39f48
Pipeline #18217 failed with stage
in 0 seconds
...@@ -102,6 +102,8 @@ class StaticWebSection(WebSection): ...@@ -102,6 +102,8 @@ class StaticWebSection(WebSection):
except AttributeError: except AttributeError:
raise KeyError(name) raise KeyError(name)
def _checkIfRenderDefaultDocument(self):
return self.REQUEST.get('portal_skin', None) or super(StaticWebSection, self)._checkIfRenderDefaultDocument()
security.declareProtected(Permissions.View, '__bobo_traverse__') security.declareProtected(Permissions.View, '__bobo_traverse__')
def __bobo_traverse__(self, request, name): def __bobo_traverse__(self, request, name):
......
...@@ -189,6 +189,9 @@ class WebSection(Domain, DocumentExtensibleTraversableMixin): ...@@ -189,6 +189,9 @@ class WebSection(Domain, DocumentExtensibleTraversableMixin):
""" """
return self return self
def _checkIfRenderDefaultDocument(self):
return not self.REQUEST.get('editable_mode') and not self.REQUEST.get('ignore_layout')
# Default view display # Default view display
security.declareProtected(Permissions.View, '__call__') security.declareProtected(Permissions.View, '__call__')
def __call__(self): def __call__(self):
...@@ -217,7 +220,7 @@ class WebSection(Domain, DocumentExtensibleTraversableMixin): ...@@ -217,7 +220,7 @@ class WebSection(Domain, DocumentExtensibleTraversableMixin):
if self.REQUEST.get(self.web_section_key, MARKER) is MARKER: if self.REQUEST.get(self.web_section_key, MARKER) is MARKER:
self.REQUEST[self.web_section_key] = self.getPhysicalPath() self.REQUEST[self.web_section_key] = self.getPhysicalPath()
self.REQUEST.set('current_web_section', self) self.REQUEST.set('current_web_section', self)
if not self.REQUEST.get('editable_mode') and not self.REQUEST.get('ignore_layout'): if self._checkIfRenderDefaultDocument():
document = None document = None
if self.isDefaultPageDisplayed(): if self.isDefaultPageDisplayed():
# The following could be moved to a typed based method for more flexibility # The following could be moved to a typed based method for more flexibility
...@@ -450,4 +453,4 @@ class WebSection(Domain, DocumentExtensibleTraversableMixin): ...@@ -450,4 +453,4 @@ class WebSection(Domain, DocumentExtensibleTraversableMixin):
else: else:
# cleanup beforeTraverse hooks that may exist after this document was cloned. # cleanup beforeTraverse hooks that may exist after this document was cloned.
self._cleanupBeforeTraverseHooks() self._cleanupBeforeTraverseHooks()
super(WebSection, self)._edit(**kw) super(WebSection, self)._edit(**kw)
\ No newline at end of file
# Don't keep any parameters when do redirect.
# This prevent duplicated parameter in redirect_url which contains already all parameters
return dict()
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>parameter_list</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_filterParameterList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -176,6 +176,12 @@ class TestStaticWebSiteRedirection(ERP5TypeTestCase): ...@@ -176,6 +176,12 @@ class TestStaticWebSiteRedirection(ERP5TypeTestCase):
def test_queryStringPortalSkin(self): def test_queryStringPortalSkin(self):
self.runTestRedirect("?portal_skin=FOOBAR") self.runTestRedirect("?portal_skin=FOOBAR")
def test_queryStringIgnoreLayoutWithQueryStringPortalSkin(self):
self.runTestRedirect("?portal_skin=FOOBAR&ignore_layout=1")
def test_queryStringEditableModeWithQueryStringPortalSkin(self):
self.runTestRedirect("?portal_skin=FOOBAR&editable_mode=1")
def test_plainRedirectGetId(self): def test_plainRedirectGetId(self):
self.runTestRedirect("getId") self.runTestRedirect("getId")
......
...@@ -40,10 +40,10 @@ class WebSectionTraversalHook(Persistent): ...@@ -40,10 +40,10 @@ class WebSectionTraversalHook(Persistent):
"""Traversal hook to change the skin selection for this websection. """Traversal hook to change the skin selection for this websection.
""" """
def __call__(self, container, request): def __call__(self, container, request):
if not request.get('ignore_layout', None): portal_skin = request.get('portal_skin', None)
if (not request.get('ignore_layout', None) and portal_skin is None) or \
(container.getPortalType() not in WEB_SECTION_PORTAL_TYPE_TUPLE and portal_skin):
# If a skin selection is defined in this web section, change the skin now. # If a skin selection is defined in this web section, change the skin now.
skin_selection_name = container.getSkinSelectionName() skin_selection_name = container.getSkinSelectionName()
if skin_selection_name and \ if skin_selection_name:
((request.get('portal_skin', None) is None) or \ container.getPortalObject().changeSkin(skin_selection_name)
container.getPortalType() not in WEB_SECTION_PORTAL_TYPE_TUPLE):
container.getPortalObject().changeSkin(skin_selection_name)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment