[Mpuls-commits] r5757 - in base/trunk/mpulsweb: lib model

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Jan 10 09:48:01 CET 2012


Author: bricks
Date: 2012-01-10 09:47:59 +0100 (Tue, 10 Jan 2012)
New Revision: 5757

Modified:
   base/trunk/mpulsweb/lib/helpers.py
   base/trunk/mpulsweb/model/phase.py
Log:
Split phase get_url method in a helper function

Helper function can be used for mpuls_S rating now too.


Modified: base/trunk/mpulsweb/lib/helpers.py
===================================================================
--- base/trunk/mpulsweb/lib/helpers.py	2012-01-09 13:43:34 UTC (rev 5756)
+++ base/trunk/mpulsweb/lib/helpers.py	2012-01-10 08:47:59 UTC (rev 5757)
@@ -416,4 +416,29 @@
         return empty
     return dd_mm_YYYY(d) + " " + HH_MM(d)
 
+def get_formular_url(formed, id, name, page=None):
+    # id is like fieldname:rgid:caseid
+    # The handling of links for Element in RG differs depending if they are
+    # located within a outline RG or not
+    # RG Types:
+    # 0 = not in rg at all
+    # 1 = within embedded rg
+    # 2 = within outline rg
+    rg_type = formed.name2rgtype.get(name, 0)
+    if page is None:
+        page = formed.name2page[name].getName()
+    element_id = ":".join(id.split(':')[1:][-1:])
+    if rg_type in (0,1):
+        # Ignore rgid, as it is not needed in this case.
+        element_id = ":".join(id.split(':')[1:][-1:])
+    else:
+        # NOTE: Nested outline RG are not supported.
+        element_id = ":".join(id.split(':')[1:][-2:])
+    anchor_id = ":".join(id.split(':')[1:])
+    print "id: %s element_id: %s anchor_id: %s" % (id, element_id, anchor_id)
+    return  url_for(controller='/formularpage', action='select',
+            id=('%s:%s' % (page, element_id)),
+            anchor=('%s:%s' % (name,
+                anchor_id)))
+
 # vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

Modified: base/trunk/mpulsweb/model/phase.py
===================================================================
--- base/trunk/mpulsweb/model/phase.py	2012-01-09 13:43:34 UTC (rev 5756)
+++ base/trunk/mpulsweb/model/phase.py	2012-01-10 08:47:59 UTC (rev 5757)
@@ -11,7 +11,7 @@
 from formed.instance.tree import PageInstanceNode
 from formed.meta.data import PageNode, RepeatNode
 
-from mpulsweb.lib.helpers import tag, url_for, literal
+from mpulsweb.lib.helpers import tag, url_for, literal, get_formular_url
 from mpulsweb.lib.helper.case import walk_it 
 from mpulsweb.lib.db import PostgresDBInterface
 
@@ -441,26 +441,8 @@
             self.conditions.append(Condition(field, rule, it))
 
     def get_url(self):
-        # self.id is like fieldname:rgid:caseid
-        # The handling of links for Element in RG differs depending if they are
-        # located within a outline RG or not
-        # RG Types:
-        # 0 = not in rg at all
-        # 1 = within embedded rg
-        # 2 = within outline rg
-        formed = self.it.getFormEd()
-        rg_type = formed.name2rgtype.get(self.name, 0)
-        if rg_type in (0,1):
-            # Ignore rgid, as it is not needed in this case.
-            element_id = ":".join(self.id.split(':')[1:][-1:])
-        else:
-            # NOTE: Nested outline RG are not supported.
-            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,
-                        anchor_id)))
+        return get_formular_url(self.it.getFormEd(), self.id, self.name,
+                                self.page)
 
     def get_link(self):
         out = []



More information about the Mpuls-commits mailing list