appy.gen: added the possibility to create and manage web pages into an app; every class can now define a method showPortlet. If the class does not define it or if it returns False, the portlet won't be shown when showing/editing instances of this class.
This commit is contained in:
parent
8aa03a091a
commit
1e9e4df5a6
9 changed files with 113 additions and 28 deletions
|
@ -223,14 +223,14 @@ class ToolMixin(BaseMixin):
|
|||
return [importParams['headers'], elems]
|
||||
|
||||
def showPortlet(self, context):
|
||||
if self.userIsAnon(): return False
|
||||
if context.id == 'ui': context = context.getParentNode()
|
||||
res = True
|
||||
if not self.getRootClasses():
|
||||
res = False
|
||||
# If there is no root class, show the portlet only if we are within
|
||||
# the configuration.
|
||||
if (self.id in context.absolute_url()): res = True
|
||||
if hasattr(context.aq_base, 'appy'):
|
||||
appyObj = context.appy()
|
||||
try:
|
||||
res = appyObj.showPortlet()
|
||||
except AttributeError:
|
||||
res = True
|
||||
return res
|
||||
|
||||
def getObject(self, uid, appy=False, brain=False):
|
||||
|
@ -1000,4 +1000,10 @@ class ToolMixin(BaseMixin):
|
|||
return '<table class="main" align="center" cellpadding="0"><tr>' \
|
||||
'<td style="padding: 1em 1em 1em 1em">An error occurred. %s' \
|
||||
'</td></tr></table>' % '\n'.join(htmlMessage)
|
||||
|
||||
def getMainPages(self):
|
||||
'''Returns the main pages.'''
|
||||
if hasattr(self.o.aq_base, 'pages') and self.o.pages:
|
||||
return [self.getObject(uid) for uid in self.o.pages ]
|
||||
return ()
|
||||
# ------------------------------------------------------------------------------
|
||||
|
|
|
@ -1312,6 +1312,9 @@ class BaseMixin:
|
|||
Else (if the object is stored directly within the tool or the root
|
||||
data folder) it returns None.'''
|
||||
parent = self.getParentNode()
|
||||
# Not-Managers can't navigate back to the tool
|
||||
if (parent.id == 'config') and not self.getUser().has_role('Manager'):
|
||||
return False
|
||||
if parent.meta_type != 'Folder': return parent
|
||||
|
||||
def index_html(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue