From a3b649582cbd6a23f161394f1c7f347d00e0a9c4 Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Wed, 4 Nov 2015 14:59:35 +0100 Subject: [PATCH] add states definition for person --- organize/stateful/README.txt | 6 +++ organize/stateful/browser.py | 1 + organize/stateful/configure.zcml | 14 +++++++ organize/stateful/person.py | 63 ++++++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+) create mode 100644 organize/stateful/person.py diff --git a/organize/stateful/README.txt b/organize/stateful/README.txt index 11182e4..d9906f1 100644 --- a/organize/stateful/README.txt +++ b/organize/stateful/README.txt @@ -181,6 +181,12 @@ Querying objects by state [<...>] +Person States +============= + + >>> from loops.organize.stateful.person import personStates + + Task States =========== diff --git a/organize/stateful/browser.py b/organize/stateful/browser.py index 2d05748..03363fe 100644 --- a/organize/stateful/browser.py +++ b/organize/stateful/browser.py @@ -44,6 +44,7 @@ template = ViewPageTemplateFile('view_macros.pt') statefulActions = ('classification_quality', 'simple_publishing', + 'person_states', 'task_states', 'publishable_task',) diff --git a/organize/stateful/configure.zcml b/organize/stateful/configure.zcml index 30ad487..89e0c73 100644 --- a/organize/stateful/configure.zcml +++ b/organize/stateful/configure.zcml @@ -35,6 +35,20 @@ set_schema="cybertools.stateful.interfaces.IStateful" /> + + + + + + + + diff --git a/organize/stateful/person.py b/organize/stateful/person.py new file mode 100644 index 0000000..06ee292 --- /dev/null +++ b/organize/stateful/person.py @@ -0,0 +1,63 @@ +# +# Copyright (c) 2015 Helmut Merz helmutm@cy55.de +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +""" +Implementations for stateful persons. +""" + +from zope.app.security.settings import Allow, Deny, Unset +from zope import component +from zope.component import adapter +from zope.interface import implementer +from zope.traversing.api import getName + +from cybertools.composer.schema.schema import Schema +from cybertools.stateful.definition import StatesDefinition +from cybertools.stateful.definition import State, Transition +from cybertools.stateful.interfaces import IStatesDefinition, IStateful +from loops.common import adapted +from loops.organize.stateful.base import commentsField +from loops.organize.stateful.base import StatefulLoopsObject +from loops.security.interfaces import ISecuritySetter +from loops.util import _ + + +defaultSchema = Schema(commentsField, + name='change_state') + + +@implementer(IStatesDefinition) +def personStates(): + return StatesDefinition('person_states', + State('prospective', 'prospective', ('activate', 'inactivate',), + color='blue'), + State('active', 'active', ('reset', 'inactivate',), + color='green'), + State('inactive', 'inactive', ('reactivate',), + color='x'), + Transition('activate', 'activate', 'active', schema=defaultSchema), + Transition('reset', 'reset', 'prospective', schema=defaultSchema), + Transition('inactivate', 'inactivate', 'inactive', schema=defaultSchema), + Transition('reactivate', 'reactivate', 'active', schema=defaultSchema), + initialState='active') + + +class StatefulPerson(StatefulLoopsObject): + + statesDefinition = 'person_states' +