bug fix: handling of date and time values

git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@3176 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2009-01-24 09:30:40 +00:00
parent 57f943707c
commit 8af44efcaf
3 changed files with 18 additions and 16 deletions

View file

@ -1,5 +1,5 @@
# #
# Copyright (c) 2008 Helmut Merz helmutm@cy55.de # Copyright (c) 2009 Helmut Merz helmutm@cy55.de
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -244,7 +244,6 @@ class DateFieldInstance(NumberFieldInstance):
try: try:
self.unmarshall(value) self.unmarshall(value)
except (TypeError, ValueError, DateTimeParseError), e: except (TypeError, ValueError, DateTimeParseError), e:
#print '*** invalid_datetime:', value, e
getLogger('cybertools').warn( getLogger('cybertools').warn(
'DateFieldInstance: invalid datetime: %s, %s' % (value, e)) 'DateFieldInstance: invalid datetime: %s, %s' % (value, e))
self.setError('invalid_datetime') self.setError('invalid_datetime')

View file

@ -206,7 +206,9 @@ class WorkItem(Stateful, Track):
return new return new
def close(self, userName, **kw): def close(self, userName, **kw):
new = self.createNew('close', userName, copyData=False, **kw) kw['start'] = kw['end'] = getTimeStamp()
kw['duration'] = kw['effort'] = None
new = self.createNew('close', userName, copyData=('title',), **kw)
new.state = 'closed' new.state = 'closed'
new.reindex('state') new.reindex('state')
getParent(self).stopRun(runId=self.runId, finish=True) getParent(self).stopRun(runId=self.runId, finish=True)
@ -233,19 +235,20 @@ class WorkItem(Stateful, Track):
for k, v in kw.items(): for k, v in kw.items():
data[k] = v data[k] = v
def createNew(self, action, userName, copyData=True, **kw): def createNew(self, action, userName, copyData=None, **kw):
if copyData is None:
copyData = self.initAttributes
newData = {} newData = {}
if copyData: for k in self.initAttributes:
for k in self.initAttributes: v = kw.get(k, _not_found)
v = kw.get(k, _not_found) if v is _not_found and k in copyData:
if v is _not_found: if action == 'start' and k in ('end',):
if action == 'start' and k in ('end',): continue
continue if action in ('work', 'finish') and k in ('duration', 'effort',):
if action in ('work', 'finish') and k in ('duration', 'effort',): continue
continue v = self.data.get(k)
v = self.data.get(k) if v not in (None, _not_found):
if v is not None: newData[k] = v
newData[k] = v
workItems = IWorkItems(getParent(self)) workItems = IWorkItems(getParent(self))
new = workItems.add(self.taskId, userName, self.runId, **newData) new = workItems.add(self.taskId, userName, self.runId, **newData)
return new return new

View file

@ -137,7 +137,7 @@ As the work is now finished, the work item may be closed; the corresponding
>>> wi06 = wi05.doAction('close', 'john') >>> wi06 = wi05.doAction('close', 'john')
>>> wi06 >>> wi06
<WorkItem ['001', 1, 'john', '... ...', 'closed']: <WorkItem ['001', 1, 'john', '... ...', 'closed']:
{'created': ..., 'creator': 'john'}> {'start': ..., 'created': ..., 'end': ..., 'creator': 'john'}>
Let's now check how many work items have been generated. Let's now check how many work items have been generated.