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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Mar 24 14:50:47 CET 2010


Author: torsten
Date: 2010-03-24 14:50:47 +0100 (Wed, 24 Mar 2010)
New Revision: 2109

Modified:
   wasko/branches/2.0/jmdweb/model/case.py
Log:
* jmdweb/model/case.py (State.isCmFinished): Get phase which are
	considered as finished CM from config. Do not differ between finished
	CM and NB in jmd.


Modified: wasko/branches/2.0/jmdweb/model/case.py
===================================================================
--- wasko/branches/2.0/jmdweb/model/case.py	2010-03-24 13:50:22 UTC (rev 2108)
+++ wasko/branches/2.0/jmdweb/model/case.py	2010-03-24 13:50:47 UTC (rev 2109)
@@ -30,9 +30,6 @@
 import sys
 from datetime import date, datetime
 import traceback
-import codecs
-import cStringIO as StringIO
-from sets import Set
 import logging
 
 import psycopg2.extras
@@ -48,24 +45,18 @@
 from mpulsweb.model.phase import PhaseFactory
 from mpulsweb.model.agencysettings import Agency
 from mpulsweb.model.case import MpulsCase, MpulsCaseFactory, MpulsCaseOverview, \
-    MpulsCaseBundle, MpulsCaseStandin
+    MpulsCaseBundle
 
-#from jmdweb.lib.csv import exportAsCSV
-#from jmdweb.lib.excel import exportAsXLS
-#from jmdweb.lib.xmlexport import exportAsXML
-
 from jmdweb.model.statement import PrivacyStatement, DiscretionStatement
 
 log = logging.getLogger(__name__)
 
-
 def save_getone(params, k, v):
     try:
         return params.getone(k)
     except KeyError:
         return v
 
-
 # SQL STATEMENTS
 LOAD_CASESTATE_SQL = """
 SELECT
@@ -360,21 +351,20 @@
     def _load(self):
         conn, cur = None, None
         try:
-            try:
-                conn = db.getConnection()
-                cur = conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
-                cur.execute(LOAD_CASESTATE_SQL, {'id': self.master_id})
-                result = cur.fetchone()
-                self.id          = result.get('id')
-                self.state       = result.get('status')
-                self.access      = result.get('zugriff')
-                self._last_date  = result.get('letzer_termin')
-                self.phase       = result.get('phase')
-            finally:
-                db.recycleConnection(conn, cur)
+            conn = db.getConnection()
+            cur = conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
+            cur.execute(LOAD_CASESTATE_SQL, {'id': self.master_id})
+            result = cur.fetchone()
+            self.id          = result.get('id')
+            self.state       = result.get('status')
+            self.access      = result.get('zugriff')
+            self._last_date  = result.get('letzer_termin')
+            self.phase       = result.get('phase')
         except:
-            traceback.print_exc(file=sys.stderr)
-        return False
+            log.exception('Failed loading State')
+            raise
+        finally:
+            db.recycleConnection(conn, cur)
 
     def getStateLabel(self):
         state_labels = {'1': _('case_state_label_open'),
@@ -385,15 +375,12 @@
                         }
         return state_labels.get(str(self.state))
 
+    def isCmFinished(self):
+        return self.phase in g.mpuls_config.get('phases', 'finished') 
+
     def getState(self):
         return self.state
 
-    def isCmFinished(self):
-        return self.phase in (4,)
-
-    def isCmCanceled(self):
-        return self.phase in (2, 3)
-
     def setState(self, value):
         conn, cur = None, None
         try:
@@ -411,6 +398,9 @@
             traceback.print_exc(file=sys.stderr)
         return False
 
+    def getPhase(self):
+        return self.phase
+
     def setPhase(self, phase):
         conn, cur = None, None
         try:
@@ -428,9 +418,6 @@
             traceback.print_exc(file=sys.stderr)
         return False
 
-    def getPhase(self):
-        return self.phase
-
     def getPhaseDescription(self):
         desc = []
         phases = PhaseFactory().load(self.master_id)
@@ -456,7 +443,7 @@
 
     def daysToMaxSavetime(self):
         maxage = self.getMaxSavetime()
-        if self.isCmFinished() or self.isCmCanceled():
+        if self.isCmFinished():
             age = datetime.now() - self.getAccessTime()
         else:
             age = datetime.now() - self.getLastDate()



More information about the Mpuls-commits mailing list