[Mpuls-commits] r2020 - wasko/branches/2.0/jmdweb/model

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Mar 19 08:28:20 CET 2010


Author: torsten
Date: 2010-03-19 08:28:20 +0100 (Fri, 19 Mar 2010)
New Revision: 2020

Modified:
   wasko/branches/2.0/jmdweb/model/case.py
Log:
* jmdweb/model/case.py (CaseStandin): Deleted. Is now defined in
  mpulsweb. 


Modified: wasko/branches/2.0/jmdweb/model/case.py
===================================================================
--- wasko/branches/2.0/jmdweb/model/case.py	2010-03-19 07:25:09 UTC (rev 2019)
+++ wasko/branches/2.0/jmdweb/model/case.py	2010-03-19 07:28:20 UTC (rev 2020)
@@ -48,7 +48,7 @@
 from mpulsweb.model.agencysettings import Agency
 from mpulsweb.model.document import listDocuments
 from mpulsweb.model.case import MpulsCase, MpulsCaseFactory, MpulsCaseOverview, \
-    MpulsCaseBundle
+    MpulsCaseBundle, MpulsCaseStandin
 
 #from jmdweb.lib.csv import exportAsCSV
 #from jmdweb.lib.excel import exportAsXLS
@@ -101,15 +101,6 @@
     mitarbeiter_name = %(nachname)s
 WHERE id = %(id)s"""
 
-LOAD_STANDIN_SQL = """
-SELECT n.benutzer_id
-FROM nm_benutzer_master_tbl_view n
-JOIN master_tbl_view m ON m.id = n.master_id
-WHERE m.id = %(id)s"""
-ADD_STANDIN_SQL = """
-SELECT create_nm_benutzer_master_ds(%(groupid)s, %(caseid)s)"""
-DELETE_STANDIN_SQL = """
-SELECT delete_nm_benutzer_master_ds(%(groupid)s, %(caseid)s)"""
 SET_EDITOR_SQL = """SELECT set_case_editor(%(userid)s, %(caseid)s)"""
 SET_EDITOR_NAME_SQL = """
 SELECT set_case_editor_name(%(firstname)s, %(lastname)s, %(caseid)s)"""
@@ -184,77 +175,6 @@
         finally:
             db.recycleConnection(conn, cur)
 
-
-class CaseStandin:
-
-    """This class represents the standin for a case"""
-
-    def __init__(self, case_id=None):
-        self.case_id = case_id
-        self.group_ids = []
-        self._loadFromDB()
-
-    def _loadFromDB(self):
-        fields = {'id': self.case_id}
-        con, cur = None, None
-        try:
-            con = db.getConnection()
-            cur = con.cursor(cursor_factory=psycopg2.extras.DictCursor)
-            cur.execute(LOAD_STANDIN_SQL, fields)
-            rows = cur.fetchall()
-            for row in rows:
-                self.group_ids.append(row['benutzer_id'])
-        finally:
-            db.recycleConnection(con, cur)
-
-    def getGroups(self):
-        """Returns a list of group ids"""
-        return self.group_ids
-
-    def setGroups(self, groupid_list):
-        """Sets the Standin to the provided list of group ids"""
-        old = Set(self.getGroups())
-        new = Set(groupid_list)
-        self._delete(old - new)
-        self._add(new - old)
-
-    def _delete(self, groupid_list):
-        con, cur = None, None
-        fields = {'caseid': self.case_id, 'groupid': None}
-        try:
-            con = db.getConnection()
-            for uid in groupid_list:
-                fields['groupid'] = uid
-                cur = con.cursor()
-                try:
-                    cur.execute(DELETE_STANDIN_SQL, fields)
-                except:
-                    con.rollback()
-                cur.close()
-                cur = None
-            con.commit()
-        finally:
-            db.recycleConnection(con, cur)
-
-    def _add(self, groupid_list):
-        con, cur = None, None
-        fields = {'caseid': self.case_id, 'groupid': None}
-        try:
-            con = db.getConnection()
-            for uid in groupid_list:
-                fields['groupid'] = uid
-                cur = con.cursor()
-                try:
-                    cur.execute(ADD_STANDIN_SQL, fields)
-                except:
-                    con.rollback()
-                cur.close()
-                cur = None
-            con.commit()
-        finally:
-            db.recycleConnection(con, cur)
-
-
 class SessionCase:
 
     """This class holds all needed information for the currently selected case
@@ -381,7 +301,7 @@
         if not self.standin is None:
             return self.standin
         try:
-            self.standin = CaseStandin(self.id)
+            self.standin = MpulsCaseStandin(self.id)
             return self.standin
         except:
             self.standin = None



More information about the Mpuls-commits mailing list