[gen] Added field appyclass.breadcrumb, allowing to show/hide the breadcrumb when displaying instances of this class; added field appyclass.resultMode, allowing to choose between 'list' or 'grid' mode (previously, only list mode was enabled) when showing instances of this class as a result of some query.
This commit is contained in:
parent
46f5b8e464
commit
c5ec54f0e5
4 changed files with 182 additions and 129 deletions
|
@ -9,7 +9,8 @@ from appy.gen.wrappers import AbstractWrapper
|
|||
from appy.gen.descriptors import ClassDescriptor
|
||||
from appy.gen.mail import sendMail
|
||||
from appy.shared import mimeTypes
|
||||
from appy.shared.utils import getOsTempFolder, sequenceTypes, normalizeString
|
||||
from appy.shared.utils import getOsTempFolder, sequenceTypes, normalizeString, \
|
||||
splitList
|
||||
from appy.shared.data import languages
|
||||
try:
|
||||
from AccessControl.ZopeSecurityPolicy import _noroles
|
||||
|
@ -224,6 +225,13 @@ class ToolMixin(BaseMixin):
|
|||
for key in self.queryParamNames])
|
||||
return res
|
||||
|
||||
def getResultMode(self, className):
|
||||
'''Must we show, on result.pt, instances of p_className as a list or
|
||||
as a grid?'''
|
||||
klass = self.getAppyClass(className)
|
||||
if hasattr(klass, 'resultMode'): return klass.resultMode
|
||||
return 'list' # The default mode
|
||||
|
||||
def getImportElements(self, contentType):
|
||||
'''Returns the list of elements that can be imported from p_path for
|
||||
p_contentType.'''
|
||||
|
@ -416,6 +424,11 @@ class ToolMixin(BaseMixin):
|
|||
return '<acronym title="%s">%s</acronym>' % \
|
||||
(text, uText[:width].encode('utf-8') + '...')
|
||||
|
||||
def splitList(self, l, sub):
|
||||
'''Returns a list made of the same elements as p_l, but grouped into
|
||||
sub-lists of p_sub elements.'''
|
||||
return splitList(l, sub)
|
||||
|
||||
def getLayoutType(self):
|
||||
'''Guess the current layout type, according to actual URL.'''
|
||||
actualUrl = self.REQUEST['ACTUAL_URL']
|
||||
|
|
|
@ -1606,7 +1606,12 @@ class BaseMixin:
|
|||
if parent.meta_type not in ('Folder', 'Temporary Folder'): return parent
|
||||
|
||||
def getBreadCrumb(self):
|
||||
'''Gets breadcrumb info about this object and its parents.'''
|
||||
'''Gets breadcrumb info about this object and its parents (if it must
|
||||
be shown).'''
|
||||
# Return an empty breadcrumb if it must not be shown.
|
||||
klass = self.getClass()
|
||||
if hasattr(klass, 'breadcrumb') and not klass.breadcrumb: return ()
|
||||
# Compute the breadcrumb
|
||||
res = [{'url': self.absolute_url(),
|
||||
'title': self.getFieldValue('title', layoutType='view')}]
|
||||
parent = self.getParent()
|
||||
|
@ -1746,7 +1751,8 @@ class BaseMixin:
|
|||
appyType = self.getAppyType(name)
|
||||
else:
|
||||
appyType = self.getAppyType(name.split('_img_')[0])
|
||||
if not appyType.isShowable(self, 'view'):
|
||||
if (not appyType.isShowable(self, 'view')) and \
|
||||
(not appyType.isShowable(self, 'result')):
|
||||
from zExceptions import NotFound
|
||||
raise NotFound()
|
||||
theFile = getattr(self.aq_base, name, None)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue