Commit fc01af6e authored by Jean-Paul Smets's avatar Jean-Paul Smets

Added a propertysheet so that the display of default page in a section can be...

Added a propertysheet so that the display of default page in a section can be turned off. This is useful for example to define translatable content through web pages in relation with a web section, although the web section should display a list of items. (ex. news, press, products in a shop, etc.)

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@22294 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 6a6b2010
...@@ -175,22 +175,23 @@ class WebSection(Domain, PermanentURLMixIn): ...@@ -175,22 +175,23 @@ class WebSection(Domain, PermanentURLMixIn):
custom_render_method_id = self.getCustomRenderMethodId() custom_render_method_id = self.getCustomRenderMethodId()
if custom_render_method_id is not None: if custom_render_method_id is not None:
return getattr(self, custom_render_method_id)() return getattr(self, custom_render_method_id)()
# The following could be moved to a typed based method for more flexibility if self.isDefaultPageDisplayed():
document = self.getDefaultDocumentValue() # The following could be moved to a typed based method for more flexibility
if document is None: document = self.getDefaultDocumentValue()
# no document found for current user, still such document may exists if document is None:
# in some cases user (like Anonymous) can not view document according to portal catalog # no document found for current user, still such document may exists
# but we may ask him to login if such a document exists # in some cases user (like Anonymous) can not view document according to portal catalog
isAuthorizationForced = getattr(self, 'isAuthorizationForced', None) # but we may ask him to login if such a document exists
if isAuthorizationForced is not None and isAuthorizationForced(): isAuthorizationForced = getattr(self, 'isAuthorizationForced', None)
getDefaultDocumentValue = UnrestrictedMethod(self.getDefaultDocumentValue) if isAuthorizationForced is not None and isAuthorizationForced():
if getDefaultDocumentValue() is not None: getDefaultDocumentValue = UnrestrictedMethod(self.getDefaultDocumentValue)
# force user to login as specified in Web Section if getDefaultDocumentValue() is not None:
raise Unauthorized # force user to login as specified in Web Section
if document is not None: raise Unauthorized
self.REQUEST.set('current_web_document', document.__of__(self)) # Used to be document if document is not None:
self.REQUEST.set('is_web_section_default_document', 1) self.REQUEST.set('current_web_document', document.__of__(self)) # Used to be document
return document.__of__(self)() self.REQUEST.set('is_web_section_default_document', 1)
return document.__of__(self)()
return Domain.__call__(self) return Domain.__call__(self)
# Layout Selection API # Layout Selection API
...@@ -222,8 +223,6 @@ class WebSection(Domain, PermanentURLMixIn): ...@@ -222,8 +223,6 @@ class WebSection(Domain, PermanentURLMixIn):
result = self._getTypeBasedMethod('getDefaultDocumentValue', result = self._getTypeBasedMethod('getDefaultDocumentValue',
fallback_script_id='WebSection_getDefaultDocumentValue')() fallback_script_id='WebSection_getDefaultDocumentValue')()
if result is not None:
result = result.__of__(self)
if cache is not None: if cache is not None:
cache[key] = result cache[key] = result
...@@ -253,8 +252,6 @@ class WebSection(Domain, PermanentURLMixIn): ...@@ -253,8 +252,6 @@ class WebSection(Domain, PermanentURLMixIn):
result = self._getTypeBasedMethod('getDocumentValueList', result = self._getTypeBasedMethod('getDocumentValueList',
fallback_script_id='WebSection_getDocumentValueList')(**kw) fallback_script_id='WebSection_getDocumentValueList')(**kw)
if result is not None:
result = [doc.__of__(self) for doc in result]
if cache is not None: if cache is not None:
cache[key] = result cache[key] = result
......
...@@ -57,6 +57,11 @@ class WebSection: ...@@ -57,6 +57,11 @@ class WebSection:
'description' : 'Defines visibility of current section.', 'description' : 'Defines visibility of current section.',
'type' : 'boolean', 'type' : 'boolean',
'mode' : 'rw' }, 'mode' : 'rw' },
{ 'id' : 'default_page_displayed',
'description' : 'Defines whether the default page should be displayed.',
'type' : 'boolean',
'default' : 1,
'mode' : 'rw' },
{ 'id' : 'custom_render_method_id', { 'id' : 'custom_render_method_id',
'description' : 'ID of a page template, script, form or any callable object' 'description' : 'ID of a page template, script, form or any callable object'
'which overrides the default rendering of the section', 'which overrides the default rendering of the section',
...@@ -74,10 +79,10 @@ class WebSection: ...@@ -74,10 +79,10 @@ class WebSection:
'acquisition_accessor_id' : 'getLayoutConfigurationFormId', 'acquisition_accessor_id' : 'getLayoutConfigurationFormId',
'acquisition_depends' : None, 'acquisition_depends' : None,
'mode' : '' }, 'mode' : '' },
{ 'id' : 'authorization_forced', { 'id' : 'authorization_forced',
'description' : 'Force authorization for anonymous user if document can not be found.', 'description' : 'Force authorization for anonymous user if document can not be found.',
'type' : 'boolean', 'type' : 'boolean',
'default': 0, 'default' : 0,
'mode' : 'rw' }, 'mode' : 'rw' },
) )
......
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