diff --git a/expert/README.txt b/expert/README.txt index c0350d6..7b96f11 100644 --- a/expert/README.txt +++ b/expert/README.txt @@ -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] diff --git a/organize/browser/event.py b/organize/browser/event.py index 1c00fba..58aa961 100644 --- a/organize/browser/event.py +++ b/organize/browser/event.py @@ -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 diff --git a/organize/browser/task.py b/organize/browser/task.py index ce7d81c..ece62d7 100644 --- a/organize/browser/task.py +++ b/organize/browser/task.py @@ -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 diff --git a/organize/stateful/base.py b/organize/stateful/base.py index b03a6ae..d38e833 100644 --- a/organize/stateful/base.py +++ b/organize/stateful/base.py @@ -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): diff --git a/organize/stateful/quality.py b/organize/stateful/quality.py index d50fa76..132aca3 100644 --- a/organize/stateful/quality.py +++ b/organize/stateful/quality.py @@ -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