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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Mar 19 09:45:54 CET 2010


Author: torsten
Date: 2010-03-19 09:45:54 +0100 (Fri, 19 Mar 2010)
New Revision: 2029

Modified:
   wasko/branches/2.0/mpulsweb/model/case.py
Log:
* jmdweb/model/case.py (Case.getEditor),(setEditor): New. copied from
  jmdweb. setEditor only defines transfering the case to the new user.
  No setting of names in forms are done.


Modified: wasko/branches/2.0/mpulsweb/model/case.py
===================================================================
--- wasko/branches/2.0/mpulsweb/model/case.py	2010-03-19 08:40:02 UTC (rev 2028)
+++ wasko/branches/2.0/mpulsweb/model/case.py	2010-03-19 08:45:54 UTC (rev 2029)
@@ -42,6 +42,7 @@
 
 from mpulsweb.model.phase import PhaseFactory, StartPhasePart, \
     ConsistenceCheckException, PHASEFIELD
+from mpulsweb.model.user import UserObject
 
 
 log = logging.getLogger(__name__)
@@ -60,6 +61,7 @@
 DELETE_STANDIN_SQL = """
 SELECT delete_nm_benutzer_master_ds(%(groupid)s, %(caseid)s)"""
 DELETE_CASE_SQL = """select delete_master_ds(%(id)s)"""
+SET_EDITOR_SQL = """SELECT set_case_editor(%(userid)s, %(caseid)s)"""
 
 #DIALOGS
 MARKANONYMIZE_FAILED_MIN_PHASE = u"""\
@@ -606,6 +608,27 @@
             raise
         return None
 
+    def getEditor(self):
+        """Returns the editor of the case"""
+        return UserObject(self.editor)
+
+    def setEditor(self, userid):
+        """sets the editor of the case to the given userid"""
+        con, curr = None, None
+        user = UserObject(userid)
+        fields = {'caseid': self.id, 'userid': userid}
+        con = db.getConnection()
+        cur = con.cursor()
+        try:
+            cur.execute(SET_EDITOR_SQL, fields)
+            con.commit()
+        except Exception, e:
+            log.exception(e)
+            con.rollback()
+        finally:
+            db.recycleConnection(con, cur)
+        return self.editor
+
     def delete(self):
         """Deletes the case from data base. Returns True if deletion succseeds
         """



More information about the Mpuls-commits mailing list