[Mpuls-commits] r4591 - in base/trunk: . mpulsweb/controllers

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Feb 8 12:33:10 CET 2011


Author: bh
Date: 2011-02-08 12:33:08 +0100 (Tue, 08 Feb 2011)
New Revision: 4591

Modified:
   base/trunk/ChangeLog
   base/trunk/mpulsweb/controllers/case.py
Log:
Fix mpuls/issue1779: setting values in repeat groups on case creation

* mpulsweb/controllers/case.py (CaseController._createCase): Rely
on the case factory's support for setting some field values during
creation instead of having more or less equivalent code duplicated
here. The code in CaseFactory is actually a bit better in that it
creates repeat group instances if necessary.
This fixes mpuls/issue1779


Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog	2011-02-07 13:50:39 UTC (rev 4590)
+++ base/trunk/ChangeLog	2011-02-08 11:33:08 UTC (rev 4591)
@@ -1,3 +1,12 @@
+2011-02-08  Bernhard Herzog  <bh at intevation.de>
+
+	* mpulsweb/controllers/case.py (CaseController._createCase): Rely
+	on the case factory's support for setting some field values during
+	creation instead of having more or less equivalent code duplicated
+	here. The code in CaseFactory is actually a bit better in that it
+	creates repeat group instances if necessary.
+	This fixes mpuls/issue1779
+
 2011-02-07  Torsten Irlaender <torsten at intevation.de>
 
 	* mpulsweb/controllers/statement.py (StatementController): New

Modified: base/trunk/mpulsweb/controllers/case.py
===================================================================
--- base/trunk/mpulsweb/controllers/case.py	2011-02-07 13:50:39 UTC (rev 4590)
+++ base/trunk/mpulsweb/controllers/case.py	2011-02-08 11:33:08 UTC (rev 4591)
@@ -14,7 +14,7 @@
 from mpulsweb.lib.dialogs import checkPrivacyStatement
 from mpulsweb.lib.validators import SetStandinForm, SetEditorForm, NewCaseForm
 from mpulsweb.lib.anonymize import determineAnonymizedCaseEndPhaseName, \
-determineAnonymizedCaseEndPhase
+     determineAnonymizedCaseEndPhase
 from mpulsweb.lib.db import  PostgresDBInterface
 from mpulsweb.model.case import ConsistenceCheckException, SessionCase, \
      MPulsXMLImporter, XMLImportException
@@ -22,7 +22,6 @@
 from mpulsweb.model.logbook import LogbookEntry
 from mpulsweb.model.statement import PrivacyStatement 
 from mpulsweb.model.agencysettings import Agency 
-from mpulsweb.controllers.formularpage import convert2dic
 
 from mpulsweb.controllers.formularpage import get_rendered_page
 
@@ -331,21 +330,7 @@
     #
 
     def _createCase(self, form_result):
-        case = g.case_factory.createNew(data=convert2dic({}))
-        case._load_formed_instance_tree()
-        # Set data
-        data = {}
-        for k in convert2dic(form_result).keys():
-            try:
-                item = case.formed_instance.getAllItemsForName(k)[0]
-                id = ":".join(item.getIdentifier().split(':')[1:])
-                data["%s:%s" % (k,id)] = form_result.get(k) 
-            except:
-                # some values within the formresult can not be found in
-                # instance tree. e.g "statement_signed"
-                pass
-            case.formed_instance.setData(data)
-            case.formed_instance.commit()
+        case = g.case_factory.createNew(data=form_result)
 
         statement = case.getPrivacyStatement()
         # 3. Do we want to sign the statement?



More information about the Mpuls-commits mailing list