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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Mar 25 09:03:01 CET 2010


Author: torsten
Date: 2010-03-25 09:03:01 +0100 (Thu, 25 Mar 2010)
New Revision: 2133

Modified:
   wasko/branches/2.0/mpulsweb/model/case.py
Log:
* mpulsweb/model/case.py (MpulsCase.getSessionCase): New. Copied from
	mpulsbase.


Modified: wasko/branches/2.0/mpulsweb/model/case.py
===================================================================
--- wasko/branches/2.0/mpulsweb/model/case.py	2010-03-25 08:00:25 UTC (rev 2132)
+++ wasko/branches/2.0/mpulsweb/model/case.py	2010-03-25 08:03:01 UTC (rev 2133)
@@ -44,6 +44,7 @@
 from mpulsweb.lib.db import PostgresDBInterface, db
 
 from mpulsweb.model.document import listDocuments
+from mpulsweb.model.statement import PrivacyStatement
 from mpulsweb.model.phase import PhaseFactory, StartPhasePart, \
     ConsistenceCheckException, PHASEFIELD
 from mpulsweb.model.user import UserObject
@@ -587,6 +588,22 @@
             raise
         return None
 
+    def getSessionCase(self):
+        """Return a SessionCase object initialized from the current case"""
+        fields = dict()
+        for field in self.get_session_fields():
+            # FIXME: Ideally we would use
+            # self.get_value(field.name) to get the value.  We use
+            # getattr instead because this compatibility layer
+            # translates None values into strings which some code
+            # (e.g. buildInfofield in
+            # templates/casemanagement/main.mako) relies on.
+            fields[field.alias] = getattr(self, field.alias)
+        signed = self.getPrivacyStatement().isSigned()
+        return SessionCase(self.id, state=self.state,
+                           privacy_statement=signed,
+                           **fields)
+
     def check_consistence(self, fields=None):
         """Raises ConsistenceCheckException if the case is not completly
         consistent up to the current phase. A case is consistent if no required



More information about the Mpuls-commits mailing list