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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Sep 22 10:32:22 CEST 2011


Author: torsten
Date: 2011-09-22 10:32:21 +0200 (Thu, 22 Sep 2011)
New Revision: 5386

Modified:
   base/trunk/mpulsweb/model/phase.py
Log:
Changed building URLs on phase page. The old code tries to find out if the
field is in an inline or outline RG and builds the URL for that field
depending on this.It seems that the code was to complicated and could be
simplified. This also fixes Issue2434. Note: This code only support one level
of outline-RG. On the other side the old code did not support multilevel
outline RG anyway. So this should be no regression.


Modified: base/trunk/mpulsweb/model/phase.py
===================================================================
--- base/trunk/mpulsweb/model/phase.py	2011-09-21 19:15:38 UTC (rev 5385)
+++ base/trunk/mpulsweb/model/phase.py	2011-09-22 08:32:21 UTC (rev 5386)
@@ -420,47 +420,25 @@
         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):
-        # 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:])
+        # [1:] Remove fieldname
+        # [-2] Only use the remaining last to ids. This means that only one
+        # level of outline RG are supported yet.
+        element_id = ":".join(self.id.split(':')[1:][-2:])
+        anchor_id = ":".join(self.id.split(':')[1:])
         return  url_for(controller='/formularpage', action='select',
                         id=('%s:%s' % (self.page, element_id)),
                         anchor=('%s:%s' % (self.name,
-                        element_id)))
+                        anchor_id)))
     def get_link(self):
         out = []
         if self.is_ok():



More information about the Mpuls-commits mailing list