[Mpuls-commits] r4921 - in base/trunk: . mpulsweb/model

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Apr 19 15:07:21 CEST 2011


Author: torsten
Date: 2011-04-19 15:07:18 +0200 (Tue, 19 Apr 2011)
New Revision: 4921

Modified:
   base/trunk/ChangeLog
   base/trunk/mpulsweb/model/phase.py
Log:
Issue2056: Check for every field where it is located. Depending on location build correct link for the phases overview to open the correct page.


Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog	2011-04-19 09:44:58 UTC (rev 4920)
+++ base/trunk/ChangeLog	2011-04-19 13:07:18 UTC (rev 4921)
@@ -1,3 +1,11 @@
+2011-04-19  Torsten Irländer <torsten.irlaender at intevation.de>
+
+	* mpulsweb/model/phase.py: Issue2056: Check for every field where it
+	is located. Depending on location build correct link for the phases
+	overview to open the correct page. TODO: This is a quickfix. I think
+	the real reason might be in the libformed returning the wrong
+	identifier.  
+
 2011-04-15  Bernhard Herzog  <bh at intevation.de>
 
 	* mpulsweb/controllers/formularpage.py: Do not import

Modified: base/trunk/mpulsweb/model/phase.py
===================================================================
--- base/trunk/mpulsweb/model/phase.py	2011-04-19 09:44:58 UTC (rev 4920)
+++ base/trunk/mpulsweb/model/phase.py	2011-04-19 13:07:18 UTC (rev 4921)
@@ -9,7 +9,7 @@
 from formed.instance.backends.postgres import DBFactory as InstanceFactory
 from formed.instance.backends.common import RuleEvalContext
 from formed.instance.tree import PageInstanceNode
-from formed.meta.data import PageNode
+from formed.meta.data import PageNode, RepeatNode
 
 from mpulsweb.lib.helpers import tag, url_for, literal
 from mpulsweb.lib.helper.case import walk_it 
@@ -413,16 +413,43 @@
         self.label = None
         self.name = None
         self.conditions = []
+        self.repeat = 0 
 
         field = self.it.getItem(self.id)
         meta = field.getMeta()
+
+        # check if the field in part on an outline rg
+        for e in meta.pathToRoot():
+            # Walk up to the root 
+            if isinstance(e, RepeatNode):
+                # is inline repeatgroup (rg with in page)
+                for f in e.pathToRoot():
+                    if isinstance(f, PageNode):
+                        self.repeat = 1
+                        break
+
+            elif isinstance(e, PageNode):
+                # is outline repeatgroup (page in rg)
+                for f in e.pathToRoot():
+                    if isinstance(f, RepeatNode):
+                        self.repeat = 2 
+                        break
+            if self.repeat != 0:
+                # we have found what we have searched for
+                break
+
         self.name = meta.getName()
         self.label = meta.getDescription()
         for rule in rules:
             self.conditions.append(Condition(field, rule, it))
 
     def get_url(self):
-        element_id = ":".join(self.id.split(':')[1:])
+        # Fix for Issue2056. Depending of where the current field is located
+        # rebuild id of the field.
+        if self.repeat in (0,2):
+            element_id = ":".join(self.id.split(':')[1:])
+        else: 
+            element_id = ":".join(self.id.split(':')[2:])
         return  url_for(controller='/formularpage', action='select',
                         id=('%s:%s' % (self.page, element_id)),
                         anchor=('%s:%s' % (self.name,



More information about the Mpuls-commits mailing list