control available states definitions by loops options
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@2558 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
24bc699e53
commit
54d238afe9
6 changed files with 51 additions and 12 deletions
|
@ -49,13 +49,14 @@ from zope.traversing.api import getName, getParent
|
|||
|
||||
from cybertools.ajax.dojo import dojoMacroTemplate
|
||||
from cybertools.browser.view import GenericView
|
||||
from cybertools.meta.interfaces import IOptions
|
||||
from cybertools.relation.interfaces import IRelationRegistry
|
||||
from cybertools.stateful.interfaces import IStateful
|
||||
from cybertools.text import mimetypes
|
||||
from cybertools.typology.interfaces import IType, ITypeManager
|
||||
from loops.common import adapted
|
||||
from loops.i18n.browser import I18NView
|
||||
from loops.interfaces import IView, INode
|
||||
from loops.interfaces import IResource, IView, INode
|
||||
from loops.resource import Resource
|
||||
from loops.security.common import canAccessObject, canListObject, canWriteObject
|
||||
from loops.type import ITypeConcept
|
||||
|
@ -320,6 +321,16 @@ class BaseView(GenericView, I18NView):
|
|||
return util.KeywordVocabulary(general
|
||||
+ self.listTypesForSearch(('resource',), ('system', 'hidden'),))
|
||||
|
||||
# options/settings
|
||||
|
||||
@Lazy
|
||||
def options(self):
|
||||
return IOptions(self.context)
|
||||
|
||||
@Lazy
|
||||
def globalOptions(self):
|
||||
return IOptions(self.loopsRoot)
|
||||
|
||||
# versioning
|
||||
|
||||
@Lazy
|
||||
|
@ -379,10 +390,13 @@ class BaseView(GenericView, I18NView):
|
|||
if not checkPermission('loops.ManageSite', self.context):
|
||||
# TODO: replace by more sensible permission
|
||||
return result
|
||||
target = self.virtualTargetObject
|
||||
for std in ['loops.classification_quality',
|
||||
'loops.simple_publishing']:
|
||||
stf = component.getAdapter(target, IStateful, name=std)
|
||||
#statesDefs = ['loops.classification_quality', 'loops.simple_publishing']
|
||||
if IResource.providedBy(self.target):
|
||||
statesDefs = self.globalOptions('organize.stateful.resource', ())
|
||||
else:
|
||||
statesDefs = ()
|
||||
for std in statesDefs:
|
||||
stf = component.getAdapter(self.target, IStateful, name=std)
|
||||
result.append(stf)
|
||||
return result
|
||||
|
||||
|
|
|
@ -40,13 +40,14 @@ from zope.lifecycleevent import Attributes
|
|||
from zope.formlib.form import Form, FormFields
|
||||
from zope.formlib.namedtemplate import NamedTemplate
|
||||
from zope.proxy import removeAllProxies
|
||||
from zope.security import canAccess, canWrite
|
||||
from zope.security import canAccess, canWrite, checkPermission
|
||||
from zope.security.proxy import removeSecurityProxy
|
||||
|
||||
from cybertools.ajax import innerHtml
|
||||
from cybertools.browser import configurator
|
||||
from cybertools.browser.action import Action
|
||||
from cybertools.browser.view import GenericView
|
||||
from cybertools.stateful.interfaces import IStateful
|
||||
from cybertools.typology.interfaces import IType, ITypeManager
|
||||
from cybertools.xedit.browser import ExternalEditorView
|
||||
from loops.browser.action import DialogAction
|
||||
|
@ -296,6 +297,8 @@ class NodeView(BaseView):
|
|||
target = getVersion(target, self.request)
|
||||
return target
|
||||
|
||||
target = virtualTargetObject
|
||||
|
||||
@Lazy
|
||||
def targetUid(self):
|
||||
if self.virtualTargetObject:
|
||||
|
@ -372,6 +375,25 @@ class NodeView(BaseView):
|
|||
if target is not None:
|
||||
return BaseView(target, self.request).url
|
||||
|
||||
# states information
|
||||
|
||||
@Lazy
|
||||
def xxx_states(self):
|
||||
result = []
|
||||
if not checkPermission('loops.ManageSite', self.context):
|
||||
# TODO: replace by more sensible permission
|
||||
return result
|
||||
target = self.virtualTargetObject
|
||||
#statesDefs = ['loops.classification_quality', 'loops.simple_publishing']
|
||||
if IResource.providedBy(target):
|
||||
statesDefs = self.globalOptions('organize.stateful.resource', ())
|
||||
else:
|
||||
statesDefs = ()
|
||||
for std in statesDefs:
|
||||
stf = component.getAdapter(target, IStateful, name=std)
|
||||
result.append(stf)
|
||||
return result
|
||||
|
||||
# target viewing and editing support
|
||||
|
||||
def getUrlForTarget(self, target):
|
||||
|
|
|
@ -185,7 +185,8 @@ class ResourceView(BaseView):
|
|||
|
||||
def getObjectActions(self, page=None, target=None):
|
||||
acts = ['info']
|
||||
acts.extend('state.' + st for st in statefulActions)
|
||||
#acts.extend('state.' + st for st in statefulActions)
|
||||
acts.extend('state.' + st.statesDefinition for st in self.states)
|
||||
if self.xeditable:
|
||||
acts.append('external_edit')
|
||||
return actions.get('object', acts, view=self, page=page, target=target)
|
||||
|
|
|
@ -137,6 +137,9 @@ We first need a node that provides us access to the resource as its target
|
|||
|
||||
The form view gives us access to the states of the object.
|
||||
|
||||
>>> loopsRoot.options = ['organize.stateful.resource:'
|
||||
... 'loops.classification_quality,loops.simple_publishing']
|
||||
|
||||
>>> form = EditObjectForm(node, TestRequest())
|
||||
>>> for st in form.states:
|
||||
... sto = st.getStateObject()
|
||||
|
|
|
@ -41,9 +41,6 @@ class StatefulLoopsObject(Stateful, StatefulAdapter):
|
|||
|
||||
adapts(ILoopsObject)
|
||||
|
||||
def getAvailableTransitionsForUser(self):
|
||||
return self.getAvailableTransitions()
|
||||
|
||||
|
||||
class SimplePublishable(StatefulLoopsObject):
|
||||
|
||||
|
|
|
@ -30,7 +30,8 @@ from cybertools.stateful.interfaces import IStateful
|
|||
from loops.util import _
|
||||
|
||||
|
||||
statefulActions = ('loops.classification_quality',)
|
||||
statefulActions = ('loops.classification_quality',
|
||||
'loops.simple_publishing',)
|
||||
|
||||
|
||||
class StateAction(Action):
|
||||
|
@ -54,7 +55,8 @@ class StateAction(Action):
|
|||
|
||||
@Lazy
|
||||
def icon(self):
|
||||
return 'cybertools.icons/led%s.png' % self.stateObject.color
|
||||
icon = self.stateObject.icon or 'led%s.png' % self.stateObject.color
|
||||
return 'cybertools.icons/' + icon
|
||||
|
||||
|
||||
for std in statefulActions:
|
||||
|
|
Loading…
Add table
Reference in a new issue