set state automatically to classified if there are parents assigned
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@2567 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
6fc13e3729
commit
1d375d5a5f
5 changed files with 33 additions and 9 deletions
|
@ -89,7 +89,7 @@ State-based queries
|
||||||
>>> for r in resources.values():
|
>>> for r in resources.values():
|
||||||
... catalog.index_doc(int(util.getUidForObject(r)), r)
|
... catalog.index_doc(int(util.getUidForObject(r)), r)
|
||||||
|
|
||||||
>>> qu = query.State('loops.classification_quality', 'new')
|
>>> qu = query.State('loops.classification_quality', 'classified')
|
||||||
>>> list(qu.apply())
|
>>> list(qu.apply())
|
||||||
[23, 25, 27]
|
[23, 25, 27]
|
||||||
|
|
||||||
|
@ -100,11 +100,11 @@ State-based queries
|
||||||
>>> from loops.organize.stateful.base import handleTransition
|
>>> from loops.organize.stateful.base import handleTransition
|
||||||
>>> component.provideHandler(handleTransition)
|
>>> component.provideHandler(handleTransition)
|
||||||
|
|
||||||
>>> statefulD001.doTransition('classify')
|
>>> statefulD001.doTransition('verify')
|
||||||
>>> list(qu.apply())
|
>>> list(qu.apply())
|
||||||
[25, 27]
|
[25, 27]
|
||||||
|
|
||||||
>>> qu = query.State('loops.classification_quality', 'classified')
|
>>> qu = query.State('loops.classification_quality', 'verified')
|
||||||
>>> list(qu.apply())
|
>>> list(qu.apply())
|
||||||
[23]
|
[23]
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ class Events(ConceptView):
|
||||||
def macro(self):
|
def macro(self):
|
||||||
return organize_macros.macros['events']
|
return organize_macros.macros['events']
|
||||||
|
|
||||||
def getActions(self, category='object', page=None):
|
def getActions(self, category='object', page=None, target=None):
|
||||||
actions = []
|
actions = []
|
||||||
if category == 'portlet':
|
if category == 'portlet':
|
||||||
actions.append(DialogAction(self, title=_(u'Create Event...'),
|
actions.append(DialogAction(self, title=_(u'Create Event...'),
|
||||||
|
@ -52,7 +52,8 @@ class Events(ConceptView):
|
||||||
typeToken='.loops/concepts/event',
|
typeToken='.loops/concepts/event',
|
||||||
fixedType=True,
|
fixedType=True,
|
||||||
innerForm='inner_concept_form.html',
|
innerForm='inner_concept_form.html',
|
||||||
page=page))
|
page=page,
|
||||||
|
target=target))
|
||||||
self.registerDojoDateWidget()
|
self.registerDojoDateWidget()
|
||||||
return actions
|
return actions
|
||||||
|
|
||||||
|
|
|
@ -36,13 +36,14 @@ organize_macros = ViewPageTemplateFile('view_macros.pt')
|
||||||
|
|
||||||
class TaskView(ConceptView):
|
class TaskView(ConceptView):
|
||||||
|
|
||||||
def getActions(self, category='object', page=None):
|
def getActions(self, category='object', page=None, target=None):
|
||||||
actions = []
|
actions = []
|
||||||
if category == 'portlet':
|
if category == 'portlet':
|
||||||
actions.append(DialogAction(self, title=_(u'Edit Task...'),
|
actions.append(DialogAction(self, title=_(u'Edit Task...'),
|
||||||
description=_(u'Modify task.'),
|
description=_(u'Modify task.'),
|
||||||
viewName='edit_concept.html',
|
viewName='edit_concept.html',
|
||||||
dialogName='editTask',
|
dialogName='editTask',
|
||||||
page=page))
|
page=page,
|
||||||
|
target=target))
|
||||||
self.registerDojoDateWidget()
|
self.registerDojoDateWidget()
|
||||||
return actions
|
return actions
|
||||||
|
|
|
@ -23,6 +23,7 @@ $Id$
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from zope.app.catalog.interfaces import ICatalog
|
from zope.app.catalog.interfaces import ICatalog
|
||||||
|
from zope.cachedescriptors.property import Lazy
|
||||||
from zope import component
|
from zope import component
|
||||||
from zope.component import adapts, adapter
|
from zope.component import adapts, adapter
|
||||||
|
|
||||||
|
@ -44,6 +45,14 @@ class StatefulLoopsObject(Stateful, StatefulAdapter):
|
||||||
|
|
||||||
adapts(ILoopsObject)
|
adapts(ILoopsObject)
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def loopsRoot(self):
|
||||||
|
return self.context.getLoopsRoot()
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def typePredicate(self):
|
||||||
|
return self.loopsRoot.getConceptManager().getTypePredicate()
|
||||||
|
|
||||||
|
|
||||||
class SimplePublishable(StatefulLoopsObject):
|
class SimplePublishable(StatefulLoopsObject):
|
||||||
|
|
||||||
|
|
|
@ -82,8 +82,9 @@ class ClassificationQualityCheckable(StatefulLoopsObject):
|
||||||
return
|
return
|
||||||
versionable = IVersionable(self.context, None)
|
versionable = IVersionable(self.context, None)
|
||||||
if self.state in ('new', 'classified', 'verified'):
|
if self.state in ('new', 'classified', 'verified'):
|
||||||
parents = self.context.getParentRelations()
|
parents = [r for r in self.context.getParentRelations()
|
||||||
if len(parents) > 1: # the hasType relation always remains
|
if r.predicate != self.typePredicate]
|
||||||
|
if len(parents) > 0:
|
||||||
self.doTransitionWithVersions('change_classification', versionable)
|
self.doTransitionWithVersions('change_classification', versionable)
|
||||||
else:
|
else:
|
||||||
self.doTransitionWithVersions('remove_classification', versionable)
|
self.doTransitionWithVersions('remove_classification', versionable)
|
||||||
|
@ -108,6 +109,18 @@ class ClassificationQualityCheckable(StatefulLoopsObject):
|
||||||
return (IResource.providedBy(self.context) and
|
return (IResource.providedBy(self.context) and
|
||||||
getName(relation.predicate) != 'hasType')
|
getName(relation.predicate) != 'hasType')
|
||||||
|
|
||||||
|
def getState(self):
|
||||||
|
value = super(ClassificationQualityCheckable, self).getState()
|
||||||
|
if value == 'new':
|
||||||
|
parents = [r for r in self.context.getParentRelations()
|
||||||
|
if r.predicate != self.typePredicate]
|
||||||
|
if len(parents) > 0:
|
||||||
|
value = 'classified'
|
||||||
|
return value
|
||||||
|
def setState(self, value):
|
||||||
|
super(ClassificationQualityCheckable, self).setState(value)
|
||||||
|
state = property(getState, setState)
|
||||||
|
|
||||||
|
|
||||||
# event handlers
|
# event handlers
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue