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
|
def setSkinName(self, skinName): self._skinName = skinName
|
||||||
skinName = property(getSkinName, setSkinName)
|
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):
|
def getLoopsRoot(self):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
|
@ -97,6 +97,7 @@ class BaseView(GenericView):
|
||||||
self.setSkin(self.loopsRoot.skinName)
|
self.setSkin(self.loopsRoot.skinName)
|
||||||
try:
|
try:
|
||||||
if not canAccess(context, 'title'):
|
if not canAccess(context, 'title'):
|
||||||
|
#raise Unauthorized
|
||||||
request.response.redirect('login.html')
|
request.response.redirect('login.html')
|
||||||
except ForbiddenAttribute: # ignore when testing
|
except ForbiddenAttribute: # ignore when testing
|
||||||
pass
|
pass
|
||||||
|
@ -246,6 +247,14 @@ class BaseView(GenericView):
|
||||||
|
|
||||||
# versioning
|
# 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
|
@Lazy
|
||||||
def versionId(self):
|
def versionId(self):
|
||||||
context = self.context
|
context = self.context
|
||||||
|
@ -260,6 +269,8 @@ class BaseView(GenericView):
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def versionInfo(self):
|
def versionInfo(self):
|
||||||
|
if not self.useVersioning:
|
||||||
|
return None
|
||||||
context = self.context
|
context = self.context
|
||||||
versionable = IVersionable(context, None)
|
versionable = IVersionable(context, None)
|
||||||
if versionable is None:
|
if versionable is None:
|
||||||
|
|
|
@ -87,7 +87,8 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th i18n:translate="label_title">Title</th>
|
<th i18n:translate="label_title">Title</th>
|
||||||
<th i18n:translate="label_type">Type</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_size">Size</th>
|
||||||
<th i18n:translate="label_modifdate">Modification Date</th>
|
<th i18n:translate="label_modifdate">Modification Date</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -103,13 +104,15 @@
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td><span tal:replace="related/longTypeTitle">Type</span></td>
|
<td><span tal:replace="related/longTypeTitle">Type</span></td>
|
||||||
<td style="text-align: center"
|
<tal:version tal:condition="view/useVersioning">
|
||||||
tal:define="versionId related/versionId">
|
<td style="text-align: center"
|
||||||
<a href="#"
|
tal:define="versionId related/versionId">
|
||||||
tal:content="versionId"
|
<a href="#"
|
||||||
tal:omit-tag="python: versionId=='1.1'"
|
tal:content="versionId"
|
||||||
tal:attributes="href string:${view/url}/.target${related/uniqueId}?loops.viewName=listversions">1.1</a>
|
tal:omit-tag="python: versionId=='1.1'"
|
||||||
</td>
|
tal:attributes="href string:${view/url}/.target${related/uniqueId}?loops.viewName=listversions">1.1</a>
|
||||||
|
</td>
|
||||||
|
</tal:version>
|
||||||
<td style="text-align: right">
|
<td style="text-align: right">
|
||||||
<span tal:replace="related/context/sizeForDisplay">Type</span>
|
<span tal:replace="related/context/sizeForDisplay">Type</span>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -584,6 +584,17 @@ class ViewPropertiesConfigurator(object):
|
||||||
return setting.get('skinName', {}).get('value', '')
|
return setting.get('skinName', {}).get('value', '')
|
||||||
skinName = property(getSkinName, setSkinName)
|
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):
|
class NodeViewConfigurator(configurator.ViewConfigurator):
|
||||||
""" Take properties from next menu item...
|
""" Take properties from next menu item...
|
||||||
|
|
|
@ -80,7 +80,7 @@
|
||||||
<require
|
<require
|
||||||
permission="zope.View"
|
permission="zope.View"
|
||||||
attributes="getLoopsRoot getLoopsUri loopsTraverse getConceptManager
|
attributes="getLoopsRoot getLoopsUri loopsTraverse getConceptManager
|
||||||
getResourceManager getViewManager skinName" />
|
getResourceManager getViewManager skinName options" />
|
||||||
|
|
||||||
<require
|
<require
|
||||||
permission="zope.ManageContent"
|
permission="zope.ManageContent"
|
||||||
|
|
|
@ -498,6 +498,13 @@ class ILoops(ILoopsObject):
|
||||||
default='',
|
default='',
|
||||||
required=False)
|
required=False)
|
||||||
|
|
||||||
|
options = schema.List(
|
||||||
|
title=_(u'Options'),
|
||||||
|
description=_(u'Additional settings.'),
|
||||||
|
value_type=schema.TextLine(),
|
||||||
|
default=[],
|
||||||
|
required=False)
|
||||||
|
|
||||||
def getLoopsUri(obj):
|
def getLoopsUri(obj):
|
||||||
""" Return the relativ path to obj, starting with '.loops/...'.
|
""" Return the relativ path to obj, starting with '.loops/...'.
|
||||||
"""
|
"""
|
||||||
|
@ -642,4 +649,11 @@ class IViewConfiguratorSchema(Interface):
|
||||||
default=u'',
|
default=u'',
|
||||||
required=False)
|
required=False)
|
||||||
|
|
||||||
|
options = schema.List(
|
||||||
|
title=_(u'Options'),
|
||||||
|
description=_(u'Additional settings.'),
|
||||||
|
value_type=schema.TextLine(),
|
||||||
|
default=[],
|
||||||
|
required=False)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,8 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th i18n:translate="label_title">Title</th>
|
<th i18n:translate="label_title">Title</th>
|
||||||
<th i18n:translate="label_type">Type</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_size">Size</th>
|
||||||
<th i18n:translate="label_modifdate">Modification Date</th>
|
<th i18n:translate="label_modifdate">Modification Date</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -66,13 +67,15 @@
|
||||||
tal:content="row/title" />
|
tal:content="row/title" />
|
||||||
</td>
|
</td>
|
||||||
<td tal:content="row/longTypeTitle|row/typeTitle">Type</td>
|
<td tal:content="row/longTypeTitle|row/typeTitle">Type</td>
|
||||||
<td style="text-align: center"
|
<tal:version condition="view/useVersioning">
|
||||||
tal:define="versionId row/versionId|string:">
|
<td style="text-align: center"
|
||||||
<a href="#"
|
tal:define="versionId row/versionId|string:">
|
||||||
tal:content="versionId"
|
<a href="#"
|
||||||
tal:omit-tag="python: versionId and versionId=='1.1'"
|
tal:content="versionId"
|
||||||
tal:attributes="href string:${view/url}/.target${row/uniqueId}?loops.viewName=listversions">1.1</a>
|
tal:omit-tag="python: versionId and versionId=='1.1'"
|
||||||
</td>
|
tal:attributes="href string:${view/url}/.target${row/uniqueId}?loops.viewName=listversions">1.1</a>
|
||||||
|
</td>
|
||||||
|
</tal:version>
|
||||||
<td style="text-align: right">
|
<td style="text-align: right">
|
||||||
<span tal:replace="row/context/sizeForDisplay|string:">Size</span>
|
<span tal:replace="row/context/sizeForDisplay|string:">Size</span>
|
||||||
</td>
|
</td>
|
||||||
|
|
Loading…
Add table
Reference in a new issue