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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Feb 24 16:41:57 CET 2010


Author: torsten
Date: 2010-02-24 16:41:57 +0100 (Wed, 24 Feb 2010)
New Revision: 1757

Modified:
   wasko/branches/2.0/mpulsweb/model/phase.py
Log:
* mpulsweb/model/phase.py (PhaseList.is_valid): new method to check if
all phases up to the current phase are valid


Modified: wasko/branches/2.0/mpulsweb/model/phase.py
===================================================================
--- wasko/branches/2.0/mpulsweb/model/phase.py	2010-02-24 15:01:52 UTC (rev 1756)
+++ wasko/branches/2.0/mpulsweb/model/phase.py	2010-02-24 15:41:57 UTC (rev 1757)
@@ -33,8 +33,21 @@
             p1, p2 = phase.getStart(), phase.getEnd()
             if p1.is_active(): return p1.id
             if p2.is_active(): return p2.id
-        return None
+        return "-1" # No phase set 
 
+    def is_valid(self):
+        '''Returns true if all phaseparts up to the current phase are ok. This
+        means all requierd fields are filled out and all checks for rules are
+        ok. Else return False'''
+        current_phase = self.get_current_phase_id()
+        for phases in self:
+            p1, p2 = phases.getStart(), phases.getEnd()
+            if p1.id <= current_phase: 
+                if not p1.is_ok(): return False
+            if p2.id <= current_phase: 
+                if not p2.is_ok(): return False
+        return True
+
 class Phase:
 
     def __init__(self, start, end, description):



More information about the Mpuls-commits mailing list