[Mpuls-commits] r5698 - base/trunk/mpulsweb/model

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Dec 7 15:51:59 CET 2011


Author: bricks
Date: 2011-12-07 15:51:59 +0100 (Wed, 07 Dec 2011)
New Revision: 5698

Modified:
   base/trunk/mpulsweb/model/phase.py
Log:
Add PhaseList.get_current() to return the actual Phase class

The method names of PhaseList are missleading get_current_phase returns
NOT the current phase class but the current PhasePart. To not break any
applications a new method get_current is added that actually returns the
the current Phase class.


Modified: base/trunk/mpulsweb/model/phase.py
===================================================================
--- base/trunk/mpulsweb/model/phase.py	2011-12-07 14:19:55 UTC (rev 5697)
+++ base/trunk/mpulsweb/model/phase.py	2011-12-07 14:51:59 UTC (rev 5698)
@@ -153,6 +153,16 @@
         p.phase = '-1'
         return p
 
+    def get_current(self):
+        '''Returns the current phase'''
+        for phase in self:
+            p1 = phase.getStart()
+            if p1.is_active():
+                return phase
+            p2 = phase.getEnd()
+            if p2.is_active():
+                return phase
+
     def get_phase(self, id):
         for p in self:
             if id == p.start.id: return p.start



More information about the Mpuls-commits mailing list