when starting a work item stop others that are running; start default date/time is 'now' for start of work
This commit is contained in:
parent
3d8a162ae5
commit
73839ea015
2 changed files with 23 additions and 3 deletions
|
@ -233,6 +233,9 @@ class WorkItem(Stateful, Track):
|
|||
(action, self.state))
|
||||
if action in self.specialActions:
|
||||
return self.specialActions[action](self, userName, **kw)
|
||||
return self.doStandardAction(action, userName, **kw)
|
||||
|
||||
def doStandardAction(self, action, userName, **kw):
|
||||
if self.state == 'new':
|
||||
self.setData(**kw)
|
||||
self.doTransition(action)
|
||||
|
@ -283,6 +286,22 @@ class WorkItem(Stateful, Track):
|
|||
delegated.data['target'] = new.name
|
||||
return new
|
||||
|
||||
def doStart(self, userName, **kw):
|
||||
action = 'start'
|
||||
# stop any running work item of user:
|
||||
if self.state != 'running':
|
||||
running = getParent(self).query(
|
||||
party=userName, state='running')
|
||||
for wi in running:
|
||||
wi.doAction('work', userName,
|
||||
end=(kw.get('start') or getTimeStamp()))
|
||||
# standard creation of new work item:
|
||||
if not kw.get('start'):
|
||||
kw['start'] = getTimeStamp()
|
||||
kw['end'] = None
|
||||
kw['duration'] = kw['effort'] = 0
|
||||
return self.doStandardAction(action, userName, **kw)
|
||||
|
||||
def move(self, userName, **kw):
|
||||
xkw = dict(kw)
|
||||
for k in ('deadline', 'start', 'end'):
|
||||
|
@ -319,7 +338,8 @@ class WorkItem(Stateful, Track):
|
|||
item.reindex('state')
|
||||
return new
|
||||
|
||||
specialActions = dict(modify=modify, delegate=delegate, move=move,
|
||||
specialActions = dict(modify=modify, delegate=delegate,
|
||||
start=doStart, move=move,
|
||||
close=close)
|
||||
|
||||
def setData(self, ignoreParty=False, **kw):
|
||||
|
|
|
@ -100,7 +100,7 @@ but may also be specified explicitly.
|
|||
>>> wi03 = wi02.doAction('start', 'jim', start=1229958000)
|
||||
>>> wi03
|
||||
<WorkItem ['001', 1, 'jim', '2008-12-22 16:00', 'running']:
|
||||
{'duration': 700, 'start': 1229958000, 'created': ..., 'creator': 'jim'}>
|
||||
{'duration': 0, 'start': 1229958000, 'created': ..., 'creator': 'jim'}>
|
||||
|
||||
Stopping and finishing work
|
||||
---------------------------
|
||||
|
@ -113,7 +113,7 @@ as "running" will be replaced by a new one.
|
|||
|
||||
>>> wi03
|
||||
<WorkItem ['001', 1, 'jim', '2008-12-22 16:00', 'replaced']:
|
||||
{'duration': 700, 'start': 1229958000, 'created': ..., 'creator': 'jim'}>
|
||||
{'duration': 0, 'start': 1229958000, 'created': ..., 'creator': 'jim'}>
|
||||
>>> wi04
|
||||
<WorkItem ['001', 1, 'jim', '2008-12-22 16:00', 'done']:
|
||||
{'start': 1229958000, 'created': ..., 'end': 1229958300, 'creator': 'jim'}>
|
||||
|
|
Loading…
Add table
Reference in a new issue