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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Feb 26 08:17:56 CET 2010


Author: torsten
Date: 2010-02-26 08:17:54 +0100 (Fri, 26 Feb 2010)
New Revision: 1823

Modified:
   wasko/branches/2.0/mpulsweb/model/case.py
Log:
Moved logic for consistence checks and anonymisation into mode.case.


Modified: wasko/branches/2.0/mpulsweb/model/case.py
===================================================================
--- wasko/branches/2.0/mpulsweb/model/case.py	2010-02-25 17:12:04 UTC (rev 1822)
+++ wasko/branches/2.0/mpulsweb/model/case.py	2010-02-26 07:17:54 UTC (rev 1823)
@@ -45,6 +45,9 @@
 
 LOAD_CASE_SQL = """SELECT %(fields)s FROM master_tbl_view WHERE id = %%(id)s"""
 
+class ConsistenceCheckException(Exception):
+    def __init__(self, value):
+        self.value = value
 
 class LoadCaseNotExistsError(Exception):
 
@@ -226,6 +229,34 @@
         """Return a list with all names of fields to match in the search"""
         return [field.name for field in cls.fields if field.search_match]
 
+    def check_consistence(self):
+        """Raises ConsistenceCheckException if the case is not completly
+        consistent up to the current phase. A case is consistent if no required
+        field are missing and all relevant dates on phases are set
+        """
+        pass
+
+    def make_consistent(self):
+        """Will ensure that the case is in a (minimal) consistent state. That
+        means that all missing required fields up to the current phase are set
+        to 'unknown'.  Missing relevant datefields (start, end) are set to the
+        current date. 
+        """
+        pass
+
+    def make_anonymizable(self):
+        """Will ensure that the case is in a anonymizable state. This means
+        that current phase is finished and the case is in a consistent state.
+        """
+        # Check if the current phase is already finished. If not then set to
+        # finished
+
+        #TODO: Implement phase setting
+
+        # Ensurse consistence of the case
+        self.make_consistent()
+
+
     def __getattr__(self, name):
         """Provide attribute like access to some fields for compatibility"""
         field = self.alias_dict.get(name)



More information about the Mpuls-commits mailing list