[Mpuls-commits] r161 - in waska/trunk: . waskaweb/model

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Sep 15 12:04:58 CEST 2008


Author: torsten
Date: 2008-09-15 12:04:57 +0200 (Mon, 15 Sep 2008)
New Revision: 161

Modified:
   waska/trunk/ChangeLog.txt
   waska/trunk/waskaweb/model/phase_transition.py
   waska/trunk/waskaweb/model/phases.py
   waska/trunk/waskaweb/model/phases_factory.py
Log:
Added support for displaying only relevant phases (commented out yet)


Modified: waska/trunk/ChangeLog.txt
===================================================================
--- waska/trunk/ChangeLog.txt	2008-09-15 09:29:54 UTC (rev 160)
+++ waska/trunk/ChangeLog.txt	2008-09-15 10:04:57 UTC (rev 161)
@@ -1,3 +1,13 @@
+2008-09-15	Torsten Irlaender  <torsten.irlaender at intevation.de>
+
+	Added support for displaying only relevant phases (commented out yet).
+
+	* waskaweb/model/phases_factory.py,
+	  waskaweb/model/phase_transition.py,
+	  waskaweb/model/phases.py: Only phases are displayed which are on the
+	  path of the current phase. E.g if this is a CM case the "beratung"
+	  will not be displayed.
+
 2008-09-15  Sascha L. Teichmann <sascha.teichmann at intevation.de>
 
 	* waskaweb/lib/security.py: Clean up usage db connection pool during

Modified: waska/trunk/waskaweb/model/phase_transition.py
===================================================================
--- waska/trunk/waskaweb/model/phase_transition.py	2008-09-15 09:29:54 UTC (rev 160)
+++ waska/trunk/waskaweb/model/phase_transition.py	2008-09-15 10:04:57 UTC (rev 161)
@@ -113,6 +113,16 @@
         phase_predecessors_path(p, path=path)
     return path
 
+def phase_successors_path(phase, path=None, include_root=False):
+    if not path:
+        path = []
+        if include_root:
+            path.append(phase)
+    for p in phase_successors(phase):
+        path.append(p)
+        phase_successors_path(p, path=path)
+    return path
+
 def phase_neighbors(phase1, phase2):
     try:
         return phase2 in PHASE_SUCCESSORS[phase1] or phase1 in PHASE_SUCCESSORS[phase2]

Modified: waska/trunk/waskaweb/model/phases.py
===================================================================
--- waska/trunk/waskaweb/model/phases.py	2008-09-15 09:29:54 UTC (rev 160)
+++ waska/trunk/waskaweb/model/phases.py	2008-09-15 10:04:57 UTC (rev 161)
@@ -29,7 +29,7 @@
 #
 
 from waskaweb.model.phase_transition import \
-    phase_neighbors, phase_symbol, phase_description, phase_predecessors_path
+    phase_neighbors, phase_symbol, phase_description, phase_predecessors_path, phase_successors_path
 
 class Phase:
 
@@ -73,8 +73,15 @@
         #for p in self.preds:
         #    if other.phase == p.phase or p.hasPredecessor(other): return True
         #return False
-        return other.phase in phase_predecessors_path(self.phase)
+        predecessors = phase_predecessors_path(self.phase)
+        print "Vorgaender: %s" % predecessors 
+        return other.phase in predecessors
 
+    def hasSuccessor(self, other):
+        successors = phase_successors_path(self.phase)
+        print "Nachfolger: %s" % successors
+        return other.phase in successors
+
     def getTime(self):
         return self.time
 

Modified: waska/trunk/waskaweb/model/phases_factory.py
===================================================================
--- waska/trunk/waskaweb/model/phases_factory.py	2008-09-15 09:29:54 UTC (rev 160)
+++ waska/trunk/waskaweb/model/phases_factory.py	2008-09-15 10:04:57 UTC (rev 161)
@@ -270,6 +270,15 @@
 
     all = {}
 
+    symbol = phase_symbol(current_phase)
+    cur_phase = Phase(
+                current_phase,
+                True,
+                required_fields.isPhaseComplete(symbol),
+                required_fields.getPhaseTime(symbol),
+                required_fields.getLinkListForPhase(symbol, navigation, link))
+    print "Aktuelle Phase: %s" % cur_phase
+
     for p1, p2, description in PAIRS:
 
         symbol = phase_symbol(p1)
@@ -294,7 +303,11 @@
 
         all[p2] = ende
 
+
+        # Only add phases which are on the path of the current phase
         pairs.append(PhasePair(start, ende, description))
+        #if cur_phase.hasSuccessor(start) or cur_phase.hasPredecessor(start) or current_phase == p1: 
+        #    pairs.append(PhasePair(start, ende, description))
 
     for p in all.itervalues():
         for pred in phase_predecessors(p.phase):



More information about the Mpuls-commits mailing list