provide 'options' field for loops root and menu objects; make versioning depend on 'useVersioning' option
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@1664 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
49a90d95f2
commit
0de032132c
7 changed files with 63 additions and 17 deletions
4
base.py
4
base.py
|
@ -51,6 +51,10 @@ class Loops(Folder):
|
|||
def setSkinName(self, skinName): self._skinName = skinName
|
||||
skinName = property(getSkinName, setSkinName)
|
||||
|
||||
def getOptions(self): return getattr(self, '_options', [])
|
||||
def setOptions(self, value): self._options = value
|
||||
options = property(getOptions, setOptions)
|
||||
|
||||
def getLoopsRoot(self):
|
||||
return self
|
||||
|
||||
|
|
|
@ -97,6 +97,7 @@ class BaseView(GenericView):
|
|||
self.setSkin(self.loopsRoot.skinName)
|
||||
try:
|
||||
if not canAccess(context, 'title'):
|
||||
#raise Unauthorized
|
||||
request.response.redirect('login.html')
|
||||
except ForbiddenAttribute: # ignore when testing
|
||||
pass
|
||||
|
@ -246,6 +247,14 @@ class BaseView(GenericView):
|
|||
|
||||
# versioning
|
||||
|
||||
@Lazy
|
||||
def useVersioning(self):
|
||||
if 'useVersioning' in self.loopsRoot.options:
|
||||
return True
|
||||
options = getattr(self.controller, 'options', None)
|
||||
if options:
|
||||
return 'useVersioning' in options.value
|
||||
|
||||
@Lazy
|
||||
def versionId(self):
|
||||
context = self.context
|
||||
|
@ -260,6 +269,8 @@ class BaseView(GenericView):
|
|||
|
||||
@Lazy
|
||||
def versionInfo(self):
|
||||
if not self.useVersioning:
|
||||
return None
|
||||
context = self.context
|
||||
versionable = IVersionable(context, None)
|
||||
if versionable is None:
|
||||
|
|
|
@ -87,7 +87,8 @@
|
|||
<tr>
|
||||
<th i18n:translate="label_title">Title</th>
|
||||
<th i18n:translate="label_type">Type</th>
|
||||
<th i18n:translate="label_version">V</th>
|
||||
<th i18n:translate="label_version"
|
||||
tal:condition="view/useVersioning">V</th>
|
||||
<th i18n:translate="label_size">Size</th>
|
||||
<th i18n:translate="label_modifdate">Modification Date</th>
|
||||
</tr>
|
||||
|
@ -103,13 +104,15 @@
|
|||
</a>
|
||||
</td>
|
||||
<td><span tal:replace="related/longTypeTitle">Type</span></td>
|
||||
<td style="text-align: center"
|
||||
tal:define="versionId related/versionId">
|
||||
<a href="#"
|
||||
tal:content="versionId"
|
||||
tal:omit-tag="python: versionId=='1.1'"
|
||||
tal:attributes="href string:${view/url}/.target${related/uniqueId}?loops.viewName=listversions">1.1</a>
|
||||
</td>
|
||||
<tal:version tal:condition="view/useVersioning">
|
||||
<td style="text-align: center"
|
||||
tal:define="versionId related/versionId">
|
||||
<a href="#"
|
||||
tal:content="versionId"
|
||||
tal:omit-tag="python: versionId=='1.1'"
|
||||
tal:attributes="href string:${view/url}/.target${related/uniqueId}?loops.viewName=listversions">1.1</a>
|
||||
</td>
|
||||
</tal:version>
|
||||
<td style="text-align: right">
|
||||
<span tal:replace="related/context/sizeForDisplay">Type</span>
|
||||
</td>
|
||||
|
|
|
@ -584,6 +584,17 @@ class ViewPropertiesConfigurator(object):
|
|||
return setting.get('skinName', {}).get('value', '')
|
||||
skinName = property(getSkinName, setSkinName)
|
||||
|
||||
def setOptions(self, options):
|
||||
ann = IAnnotations(self.context)
|
||||
setting = ann.get(configurator.ANNOTATION_KEY, {})
|
||||
setting['options'] = {'value': options}
|
||||
ann[configurator.ANNOTATION_KEY] = setting
|
||||
def getOptions(self):
|
||||
ann = IAnnotations(self.context)
|
||||
setting = ann.get(configurator.ANNOTATION_KEY, {})
|
||||
return setting.get('options', {}).get('value', [])
|
||||
options = property(getOptions, setOptions)
|
||||
|
||||
|
||||
class NodeViewConfigurator(configurator.ViewConfigurator):
|
||||
""" Take properties from next menu item...
|
||||
|
|
|
@ -80,7 +80,7 @@
|
|||
<require
|
||||
permission="zope.View"
|
||||
attributes="getLoopsRoot getLoopsUri loopsTraverse getConceptManager
|
||||
getResourceManager getViewManager skinName" />
|
||||
getResourceManager getViewManager skinName options" />
|
||||
|
||||
<require
|
||||
permission="zope.ManageContent"
|
||||
|
|
|
@ -498,6 +498,13 @@ class ILoops(ILoopsObject):
|
|||
default='',
|
||||
required=False)
|
||||
|
||||
options = schema.List(
|
||||
title=_(u'Options'),
|
||||
description=_(u'Additional settings.'),
|
||||
value_type=schema.TextLine(),
|
||||
default=[],
|
||||
required=False)
|
||||
|
||||
def getLoopsUri(obj):
|
||||
""" Return the relativ path to obj, starting with '.loops/...'.
|
||||
"""
|
||||
|
@ -642,4 +649,11 @@ class IViewConfiguratorSchema(Interface):
|
|||
default=u'',
|
||||
required=False)
|
||||
|
||||
options = schema.List(
|
||||
title=_(u'Options'),
|
||||
description=_(u'Additional settings.'),
|
||||
value_type=schema.TextLine(),
|
||||
default=[],
|
||||
required=False)
|
||||
|
||||
|
||||
|
|
|
@ -50,7 +50,8 @@
|
|||
<tr>
|
||||
<th i18n:translate="label_title">Title</th>
|
||||
<th i18n:translate="label_type">Type</th>
|
||||
<th i18n:translate="label_version">V</th>
|
||||
<th i18n:translate="label_version"
|
||||
tal:condition="view/useVersioning">V</th>
|
||||
<th i18n:translate="label_size">Size</th>
|
||||
<th i18n:translate="label_modifdate">Modification Date</th>
|
||||
</tr>
|
||||
|
@ -66,13 +67,15 @@
|
|||
tal:content="row/title" />
|
||||
</td>
|
||||
<td tal:content="row/longTypeTitle|row/typeTitle">Type</td>
|
||||
<td style="text-align: center"
|
||||
tal:define="versionId row/versionId|string:">
|
||||
<a href="#"
|
||||
tal:content="versionId"
|
||||
tal:omit-tag="python: versionId and versionId=='1.1'"
|
||||
tal:attributes="href string:${view/url}/.target${row/uniqueId}?loops.viewName=listversions">1.1</a>
|
||||
</td>
|
||||
<tal:version condition="view/useVersioning">
|
||||
<td style="text-align: center"
|
||||
tal:define="versionId row/versionId|string:">
|
||||
<a href="#"
|
||||
tal:content="versionId"
|
||||
tal:omit-tag="python: versionId and versionId=='1.1'"
|
||||
tal:attributes="href string:${view/url}/.target${row/uniqueId}?loops.viewName=listversions">1.1</a>
|
||||
</td>
|
||||
</tal:version>
|
||||
<td style="text-align: right">
|
||||
<span tal:replace="row/context/sizeForDisplay|string:">Size</span>
|
||||
</td>
|
||||
|
|
Loading…
Add table
Reference in a new issue