From 8af44efcaf35baa94c12ff221ce2c0e904bba3f9 Mon Sep 17 00:00:00 2001 From: helmutm Date: Sat, 24 Jan 2009 09:30:40 +0000 Subject: [PATCH] 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 --- composer/schema/field.py | 3 +-- organize/work.py | 29 ++++++++++++++++------------- organize/work.txt | 2 +- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/composer/schema/field.py b/composer/schema/field.py index d47b42e..8958fe4 100644 --- a/composer/schema/field.py +++ b/composer/schema/field.py @@ -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 # it under the terms of the GNU General Public License as published by @@ -244,7 +244,6 @@ class DateFieldInstance(NumberFieldInstance): try: self.unmarshall(value) except (TypeError, ValueError, DateTimeParseError), e: - #print '*** invalid_datetime:', value, e getLogger('cybertools').warn( 'DateFieldInstance: invalid datetime: %s, %s' % (value, e)) self.setError('invalid_datetime') diff --git a/organize/work.py b/organize/work.py index a7c6647..ab384a2 100644 --- a/organize/work.py +++ b/organize/work.py @@ -206,7 +206,9 @@ class WorkItem(Stateful, Track): return new 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.reindex('state') getParent(self).stopRun(runId=self.runId, finish=True) @@ -233,19 +235,20 @@ class WorkItem(Stateful, Track): for k, v in kw.items(): 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 = {} - if copyData: - for k in self.initAttributes: - v = kw.get(k, _not_found) - if v is _not_found: - if action == 'start' and k in ('end',): - continue - if action in ('work', 'finish') and k in ('duration', 'effort',): - continue - v = self.data.get(k) - if v is not None: - newData[k] = v + for k in self.initAttributes: + v = kw.get(k, _not_found) + if v is _not_found and k in copyData: + if action == 'start' and k in ('end',): + continue + if action in ('work', 'finish') and k in ('duration', 'effort',): + continue + v = self.data.get(k) + if v not in (None, _not_found): + newData[k] = v workItems = IWorkItems(getParent(self)) new = workItems.add(self.taskId, userName, self.runId, **newData) return new diff --git a/organize/work.txt b/organize/work.txt index f6de75a..bcf91af 100644 --- a/organize/work.txt +++ b/organize/work.txt @@ -137,7 +137,7 @@ As the work is now finished, the work item may be closed; the corresponding >>> wi06 = wi05.doAction('close', 'john') >>> wi06 + {'start': ..., 'created': ..., 'end': ..., 'creator': 'john'}> Let's now check how many work items have been generated.