make client stateful; fix detail data listing: ignore read-only fields
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@3706 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
5c8fd1c825
commit
c6d80925eb
2 changed files with 51 additions and 3 deletions
|
@ -33,6 +33,7 @@ from cybertools.composer.schema.browser.common import BaseView
|
|||
from cybertools.composer.schema.client import eventTypes, getCheckoutRule
|
||||
from cybertools.composer.schema.interfaces import IClientFactory, ISchema
|
||||
from cybertools.composer.schema.schema import FormState
|
||||
from cybertools.stateful.interfaces import IStateful
|
||||
from cybertools.util.jeep import Jeep
|
||||
|
||||
|
||||
|
@ -123,12 +124,16 @@ class FormManagerView(BaseView):
|
|||
break
|
||||
return False
|
||||
|
||||
def overview(self):
|
||||
def overview(self, ignoreTemporary=True):
|
||||
result = []
|
||||
for c in self.context.getClients().values():
|
||||
state = IStateful(c).state
|
||||
if ignoreTemporary and state == 'temporary':
|
||||
continue
|
||||
instance = IInstance(c)
|
||||
data = instance.applyTemplate()
|
||||
data['id'] = data['__name__']
|
||||
data['state'] = state
|
||||
result.append(data)
|
||||
return result
|
||||
|
||||
|
@ -142,7 +147,8 @@ class FormManagerView(BaseView):
|
|||
instance.template = s
|
||||
data = instance.applyTemplate()
|
||||
for f in s.fields:
|
||||
result.append(dict(label=f.title, value=data[f.name]))
|
||||
if f.storeData:
|
||||
result.append(dict(label=f.title, value=data.get(f.name)))
|
||||
return result
|
||||
|
||||
|
||||
|
@ -173,6 +179,10 @@ class CheckoutView(BaseView):
|
|||
client = self.getClient()
|
||||
if client is None:
|
||||
return True # TODO: error, redirect to overview
|
||||
# submit
|
||||
stf = IStateful(client)
|
||||
if stf.state == 'temporary':
|
||||
stf.doTransition('submit')
|
||||
# send mail
|
||||
rm = IRuleManager(self.context)
|
||||
rm.addRule(getCheckoutRule(self.context.senderEmail))
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2007 Helmut Merz helmutm@cy55.de
|
||||
# Copyright (c) 2010 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
|
||||
|
@ -33,6 +33,10 @@ from cybertools.composer.rule.base import RuleManager, EventType
|
|||
from cybertools.composer.rule.base import Rule, Action
|
||||
from cybertools.composer.schema.interfaces import IClient
|
||||
from cybertools.composer.schema.interfaces import IClientManager, IClientFactory
|
||||
from cybertools.stateful.base import StatefulAdapter
|
||||
from cybertools.stateful.definition import registerStatesDefinition
|
||||
from cybertools.stateful.definition import StatesDefinition
|
||||
from cybertools.stateful.definition import State, Transition
|
||||
from cybertools.util.jeep import Jeep
|
||||
from cybertools.util.randomname import generateName
|
||||
|
||||
|
@ -124,6 +128,40 @@ class RuleManagerAdapter(RuleManager):
|
|||
self.context = context
|
||||
|
||||
|
||||
# registration states
|
||||
|
||||
clientStates = 'composer.schema.client'
|
||||
|
||||
registerStatesDefinition(
|
||||
StatesDefinition(clientStates,
|
||||
State('temporary', 'temporary', ('submit', 'cancel',)),
|
||||
State('submitted', 'submitted',
|
||||
('change', 'retract', 'confirm', 'reject',)),
|
||||
State('cancelled', 'cancelled', ('activate',)),
|
||||
State('retracted', 'retracted', ('activate', 'cancel',)),
|
||||
State('confirmed', 'confirmed',
|
||||
('change', 'retract', 'reject',)),
|
||||
State('rejected', 'rejected',
|
||||
('change', 'retract', 'confirm',)),
|
||||
Transition('cancel', 'Cancel registration', 'cancelled'),
|
||||
Transition('submit', 'Submit registration', 'submitted'),
|
||||
Transition('change', 'Change registration', 'submitted'),
|
||||
Transition('retract', 'Retract registration', 'retracted'),
|
||||
Transition('activate', 'Activate cancelled registration',
|
||||
'temporary'),
|
||||
Transition('confirm', 'Confirm registration', 'confirmed'),
|
||||
Transition('reject', 'Reject registration', 'rejected'),
|
||||
initialState='temporary',
|
||||
))
|
||||
|
||||
|
||||
class StatefulClient(StatefulAdapter):
|
||||
|
||||
adapts(IClient)
|
||||
|
||||
statesDefinition = clientStates
|
||||
|
||||
|
||||
eventTypes = Jeep((
|
||||
EventType('client.checkout'),
|
||||
))
|
||||
|
|
Loading…
Add table
Reference in a new issue