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