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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Apr 23 10:47:15 CEST 2010


Author: torsten
Date: 2010-04-23 10:47:10 +0200 (Fri, 23 Apr 2010)
New Revision: 2503

Modified:
   wasko/branches/2.0/mpulsweb/model/case.py
Log:
* mpulsweb/model/case.py (MpulsCase.check_consistence),
	(MpulsCase.make_consistent): Commit changes after setting the data
* mpulsweb/model/case.py (get_unknown_value): Return "unbekannt" as
	default unknown value for datefields


Modified: wasko/branches/2.0/mpulsweb/model/case.py
===================================================================
--- wasko/branches/2.0/mpulsweb/model/case.py	2010-04-23 08:26:24 UTC (rev 2502)
+++ wasko/branches/2.0/mpulsweb/model/case.py	2010-04-23 08:47:10 UTC (rev 2503)
@@ -121,11 +121,11 @@
     def __str__(self):
         return repr(self.value)
 
-def get_default_value(item):
+def get_unknown_value(item):
     """Will return the default value for a instance tree item"""
     meta = item.getMeta()
     if isinstance(meta, DateLeaf):
-        value = '01.01.0001'
+        value = 'unbekannt'
     elif isinstance(meta, IntLeaf):
        value = '-999999'
     elif isinstance(meta, TextLeaf):
@@ -703,7 +703,7 @@
                 value = item.getValue()
                 log.debug('Current value of %s: %s' % (field.name, value))
                 if value in [-1, "-1", None, ""]:
-                    def_value = get_default_value(item)
+                    def_value = get_unknown_value(item)
                     if def_value:
                         log.debug("Setting %s to %s" % (field.name, def_value))
                         data["%s:%s" % (field.name, self.id)] = def_value
@@ -712,13 +712,14 @@
                 value = item.getValue()
                 log.debug('Current value of %s: %s' % (field.name, value))
                 if item.getValue() in [-1, "-1", None, ""]:
-                    def_value = get_default_value(item)
+                    def_value = get_unknown_value(item)
                     if def_value:
                         log.debug("Setting %s to %s" % (field.name, def_value))
                         data["%s:%s" % (field.name, self.id)] = def_value
 
         # Set values
         self.formed_instance.setData(data)
+        self.formed_instance.commit()
 
     def make_anonymizable(self):
         """Will ensure that the case is in a anonymizable state. This means
@@ -732,6 +733,7 @@
         end_phase = determineAnonymizedCaseEndPhase(self)
         data['%s:%s' % (PHASEFIELD, self.id)] = str(end_phase)
         self.formed_instance.setData(data)
+        self.formed_instance.commit()
 
         # Ensurse consistence of the case
         self.make_consistent()



More information about the Mpuls-commits mailing list