[Mpuls-commits] r140 - in waska/trunk: . waskaweb/model waskaweb/templates/casemanagement

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Sep 8 17:27:41 CEST 2008


Author: teichmann
Date: 2008-09-08 17:27:40 +0200 (Mon, 08 Sep 2008)
New Revision: 140

Modified:
   waska/trunk/ChangeLog.txt
   waska/trunk/waskaweb/model/phases.py
   waska/trunk/waskaweb/model/phases_factory.py
   waska/trunk/waskaweb/templates/casemanagement/phase.mako
Log:
Eval state switching recursively depending on the completeness of the preds.


Modified: waska/trunk/ChangeLog.txt
===================================================================
--- waska/trunk/ChangeLog.txt	2008-09-08 13:24:26 UTC (rev 139)
+++ waska/trunk/ChangeLog.txt	2008-09-08 15:27:40 UTC (rev 140)
@@ -1,3 +1,12 @@
+2008-09-08  Sascha L. Teichmann <sascha.teichmann at intevation.de>
+
+	* waskaweb/model/phases_factory.py: Build a list of preds for each phase
+
+	* waskaweb/model/phases.py: track preds, too
+
+	* waskaweb/templates/casemanagement/phase.mako: eval the possibility to
+	  activate phase recursively depending on the completeness of the preds.
+
 2008-09-08	Torsten Irlaender  <torsten.irlaender at intevation.de>
 
 	Added more inconsistency checks

Modified: waska/trunk/waskaweb/model/phases.py
===================================================================
--- waska/trunk/waskaweb/model/phases.py	2008-09-08 13:24:26 UTC (rev 139)
+++ waska/trunk/waskaweb/model/phases.py	2008-09-08 15:27:40 UTC (rev 140)
@@ -39,6 +39,7 @@
         self.complete = complete
         self.time     = time
         self.links    = links
+        self.preds    = []
 
     def isNeighbor(self, other):
         return phase_neighbors(self.phase, other.phase)
@@ -46,6 +47,9 @@
     def isRunning(self):
         return self.running
 
+    def addPredecessor(self, pred):
+        self.preds.append(pred)
+
     def getLabel(self):
         return phase_symbol(self.phase)
 
@@ -55,6 +59,16 @@
     def isComplete(self):
         return self.complete
 
+    def isRecursiveComplete(self):
+        if not self.complete:
+            return False
+
+        for pred in self.preds:
+            if not pred.isComplete():
+                return False
+
+        return True
+
     def getTime(self):
         return self.time
 

Modified: waska/trunk/waskaweb/model/phases_factory.py
===================================================================
--- waska/trunk/waskaweb/model/phases_factory.py	2008-09-08 13:24:26 UTC (rev 139)
+++ waska/trunk/waskaweb/model/phases_factory.py	2008-09-08 15:27:40 UTC (rev 140)
@@ -28,8 +28,6 @@
 # Sascha L. Teichmann <sascha.teichmann at intevation.de>
 #
 
-import sys
-
 from waskaweb.model.phases           import *
 from waskaweb.model.phase_transition import *
 
@@ -69,7 +67,6 @@
         if p:
             ti = navigation.findTreeItemByPageName(p.getName())
             if ti: return link(ti)
-#                '"/case/show/%d/%s"' % (ti.realId(case_id), ti.key)
     return '"/case/required/%s" target="_blank"' % item.getName()
 
 class RequiredFields:
@@ -102,7 +99,7 @@
                     # TODO: Fix formed tree
                     if p[0] == "required":
                         all.append([nc, None])
-                    if p[0] == "time":
+                    elif p[0] == "time":
                         all_times.append([nc, None])
 
         for a in all:
@@ -116,10 +113,6 @@
         for v in phases.itervalues():
             v.sort(cmp=lambda a, b: cmp(description(a[0]), description(b[0])))
 
-        #for k in sorted(phases.iterkeys()):
-        #    print >> sys.stderr, "phase '%s': %s" % (
-        #        k, ', '.join([nc[0].getName() for nc in phases[k]]))
-
         self.phases = phases
         self.times  = times
             
@@ -190,8 +183,6 @@
 
         select = SELECT % ', '.join(select_terms)
 
-        #print >> sys.stderr, '%s' % select
-
         cur.execute(select, { 'id': ds_id })
         row = cur.fetchone()
         if not row: return False
@@ -203,8 +194,6 @@
             for b in a:
                 b[1] = fields.get(b[0].getName())
 
-        # print >> sys.stderr, repr(self.phases.keys())
-
         return True
 
     def getPhase(self, phase):
@@ -255,6 +244,8 @@
 
     pairs = []
 
+    all = {}
+
     for p1, p2, description in PAIRS:
 
         symbol = phase_symbol(p1)
@@ -266,6 +257,8 @@
             required_fields.getPhaseTime(symbol),
             required_fields.getLinkListForPhase(symbol, navigation, link))
 
+        all[p1] = start
+
         symbol = phase_symbol(p2)
 
         ende = Phase(
@@ -275,8 +268,17 @@
             required_fields.getPhaseTime(symbol),
             required_fields.getLinkListForPhase(symbol, navigation, link))
 
+        all[p2] = ende
+
         pairs.append(PhasePair(start, ende, description))
 
+    for p in all.itervalues():
+        for pred in phase_predecessors(p.phase):
+            try:
+                p.addPredecessor(all[pred])
+            except KeyError:
+                pass
+
     return pairs
 
 # vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:

Modified: waska/trunk/waskaweb/templates/casemanagement/phase.mako
===================================================================
--- waska/trunk/waskaweb/templates/casemanagement/phase.mako	2008-09-08 13:24:26 UTC (rev 139)
+++ waska/trunk/waskaweb/templates/casemanagement/phase.mako	2008-09-08 15:27:40 UTC (rev 140)
@@ -23,7 +23,7 @@
     <tr>
       <td rowspan="2" class="cm_phase_state">
         ${phase_pair.getDescription() | h}
-        % if phase_pair.isRunning():
+        % if p1.isRunning():
             <br>(läuft)
         % endif
       </td>
@@ -37,7 +37,7 @@
       </td>
       <td>${h.dd_mm_YYYY(p1.getTime(), '-/-')}</td>
       <td style="text-align:right">
-        % if p1.isComplete() and not p1.isRunning() and p1.isNeighbor(c.current_phase):
+        % if p1.isRecursiveComplete() and not p1.isRunning() and p1.isNeighbor(c.current_phase):
             <input type="submit" value="Start ${phase_pair.getDescription()|h}" name="${p1.getLabel()|h}">
         % else:
             <input type="submit" value="Start ${phase_pair.getDescription()|h}" name="${p1.getLabel()|h}"
@@ -56,7 +56,7 @@
       </td>
       <td class="table_row_h">${h.dd_mm_YYYY(p2.getTime(), '-/-')}</td>
       <td style="text-align:right" class="table_row_h">
-        % if p2.isComplete() and p2.isRunning():
+        % if p2.isRecursiveComplete() and p2.isNeighbor(c.current_phase):
             <input type="submit" value="Ende ${p2.getDescription()|h}" name="${p2.getLabel()|h}">
         % else:
             <input type="submit" value="Ende ${p2.getDescription()|h}" name="${p2.getLabel()|h}" 



More information about the Mpuls-commits mailing list