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():
|
||||
... 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())
|
||||
[23, 25, 27]
|
||||
|
||||
|
@ -100,11 +100,11 @@ State-based queries
|
|||
>>> from loops.organize.stateful.base import handleTransition
|
||||
>>> component.provideHandler(handleTransition)
|
||||
|
||||
>>> statefulD001.doTransition('classify')
|
||||
>>> statefulD001.doTransition('verify')
|
||||
>>> list(qu.apply())
|
||||
[25, 27]
|
||||
|
||||
>>> qu = query.State('loops.classification_quality', 'classified')
|
||||
>>> qu = query.State('loops.classification_quality', 'verified')
|
||||
>>> list(qu.apply())
|
||||
[23]
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ class Events(ConceptView):
|
|||
def macro(self):
|
||||
return organize_macros.macros['events']
|
||||
|
||||
def getActions(self, category='object', page=None):
|
||||
def getActions(self, category='object', page=None, target=None):
|
||||
actions = []
|
||||
if category == 'portlet':
|
||||
actions.append(DialogAction(self, title=_(u'Create Event...'),
|
||||
|
@ -52,7 +52,8 @@ class Events(ConceptView):
|
|||
typeToken='.loops/concepts/event',
|
||||
fixedType=True,
|
||||
innerForm='inner_concept_form.html',
|
||||
page=page))
|
||||
page=page,
|
||||
target=target))
|
||||
self.registerDojoDateWidget()
|
||||
return actions
|
||||
|
||||
|
|
|
@ -36,13 +36,14 @@ organize_macros = ViewPageTemplateFile('view_macros.pt')
|
|||
|
||||
class TaskView(ConceptView):
|
||||
|
||||
def getActions(self, category='object', page=None):
|
||||
def getActions(self, category='object', page=None, target=None):
|
||||
actions = []
|
||||
if category == 'portlet':
|
||||
actions.append(DialogAction(self, title=_(u'Edit Task...'),
|
||||
description=_(u'Modify task.'),
|
||||
viewName='edit_concept.html',
|
||||
dialogName='editTask',
|
||||
page=page))
|
||||
page=page,
|
||||
target=target))
|
||||
self.registerDojoDateWidget()
|
||||
return actions
|
||||
|
|
|
@ -23,6 +23,7 @@ $Id$
|
|||
"""
|
||||
|
||||
from zope.app.catalog.interfaces import ICatalog
|
||||
from zope.cachedescriptors.property import Lazy
|
||||
from zope import component
|
||||
from zope.component import adapts, adapter
|
||||
|
||||
|
@ -44,6 +45,14 @@ class StatefulLoopsObject(Stateful, StatefulAdapter):
|
|||
|
||||
adapts(ILoopsObject)
|
||||
|
||||
@Lazy
|
||||
def loopsRoot(self):
|
||||
return self.context.getLoopsRoot()
|
||||
|
||||
@Lazy
|
||||
def typePredicate(self):
|
||||
return self.loopsRoot.getConceptManager().getTypePredicate()
|
||||
|
||||
|
||||
class SimplePublishable(StatefulLoopsObject):
|
||||
|
||||
|
|
|
@ -82,8 +82,9 @@ class ClassificationQualityCheckable(StatefulLoopsObject):
|
|||
return
|
||||
versionable = IVersionable(self.context, None)
|
||||
if self.state in ('new', 'classified', 'verified'):
|
||||
parents = self.context.getParentRelations()
|
||||
if len(parents) > 1: # the hasType relation always remains
|
||||
parents = [r for r in self.context.getParentRelations()
|
||||
if r.predicate != self.typePredicate]
|
||||
if len(parents) > 0:
|
||||
self.doTransitionWithVersions('change_classification', versionable)
|
||||
else:
|
||||
self.doTransitionWithVersions('remove_classification', versionable)
|
||||
|
@ -108,6 +109,18 @@ class ClassificationQualityCheckable(StatefulLoopsObject):
|
|||
return (IResource.providedBy(self.context) and
|
||||
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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue