[Mpuls-commits] r2638 - wasko/branches/2.0/mpulsweb/model

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed May 5 11:05:19 CEST 2010


Author: torsten
Date: 2010-05-05 11:05:17 +0200 (Wed, 05 May 2010)
New Revision: 2638

Modified:
   wasko/branches/2.0/mpulsweb/model/case.py
Log:
* mpulsweb/model/case.py (MpulsCase.make_consistent): Fixed function
  to make the case consistent. Phase relevant dates are now set to the
  current date.


Modified: wasko/branches/2.0/mpulsweb/model/case.py
===================================================================
--- wasko/branches/2.0/mpulsweb/model/case.py	2010-05-05 08:32:03 UTC (rev 2637)
+++ wasko/branches/2.0/mpulsweb/model/case.py	2010-05-05 09:05:17 UTC (rev 2638)
@@ -43,7 +43,7 @@
 from mpulsweb.lib.base import g, h, session
 from mpulsweb.lib.export import XLSExport, CSVExport 
 from mpulsweb.lib.anonymize import determineAnonymizedCaseEndPhase
-from mpulsweb.lib.helpers import ensure_unicode
+from mpulsweb.lib.helpers import ensure_unicode, format_date
 from mpulsweb.lib.db import PostgresDBInterface, db
 
 from mpulsweb.model.document import listDocuments
@@ -733,7 +733,19 @@
             start, end = phase.getStart(), phase.getEnd()
             if start.id > curphase:
                 break
+
+            # set relevant start and enddate to the current date if not already
+            # set
+            if start.date in [None, ""]:
+                key = "%s:%s" % (start.datefield, self.id)
+                data[key] = format_date(datetime.today())
+            if end.date in [None, ""]: 
+                key = "%s:%s" % (end.datefield, self.id)
+                data[key] = format_date(datetime.today())
+
+            # Fill all other fields with "unknown" values.
             for field in start.fields:
+                if data.has_key("%s:%s" % (field.name, self.id)): continue
                 item = self._get_formed_item(field.name)
                 value = item.getValue()
                 log.debug('Current value of %s: %s' % (field.name, value))
@@ -743,6 +755,7 @@
                         log.debug("Setting %s to %s" % (field.name, def_value))
                         data["%s:%s" % (field.name, self.id)] = def_value
             for field in end.fields:
+                if data.has_key("%s:%s" % (field.name, self.id)): continue
                 item = self._get_formed_item(field.name)
                 value = item.getValue()
                 log.debug('Current value of %s: %s' % (field.name, value))



More information about the Mpuls-commits mailing list