[Mpuls-commits] r5399 - waska/branches/waska3/waskaweb/model

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Sep 29 15:30:01 CEST 2011


Author: roland
Date: 2011-09-29 15:30:01 +0200 (Thu, 29 Sep 2011)
New Revision: 5399

Modified:
   waska/branches/waska3/waskaweb/model/case.py
Log:
issue2461: fill in the agency's name when initialising new cases


Modified: waska/branches/waska3/waskaweb/model/case.py
===================================================================
--- waska/branches/waska3/waskaweb/model/case.py	2011-09-29 13:21:12 UTC (rev 5398)
+++ waska/branches/waska3/waskaweb/model/case.py	2011-09-29 13:30:01 UTC (rev 5399)
@@ -40,6 +40,14 @@
 
 log = logging.getLogger(__name__)
 
+
+# SQL STATEMENTS
+INIT_CASE_SQL = """
+UPDATE master_tbl_view
+SET
+    einrichtung_name = %(einrichtung_name)s
+WHERE id = %(id)s"""
+
 class CaseBundle(MpulsCaseBundle):
     pass
 
@@ -50,7 +58,21 @@
     pass
 
 class CaseFactory(MpulsCaseFactory):
-    pass
+    def _initNewCase(self, id):
+        conn, cur = None, None
+        try:
+            user = session['USER_AUTHORIZED']
+            agency = Agency()
+            fields = {
+                'einrichtung_name': agency.getName() or None,
+                'id': int(id)
+                }
+            conn = db.getConnection()
+            cur = conn.cursor()
+            cur.execute(INIT_CASE_SQL, fields)
+            conn.commit()
+        finally:
+            db.recycleConnection(conn, cur)
 
 class Case(MpulsCase):
 



More information about the Mpuls-commits mailing list