[Mpuls-commits] r3835 - in base/trunk: . mpulsweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Sep 30 19:10:27 CEST 2010


Author: bh
Date: 2010-09-30 19:10:25 +0200 (Thu, 30 Sep 2010)
New Revision: 3835

Modified:
   base/trunk/ChangeLog
   base/trunk/mpulsweb/lib/renderer.py
Log:
* mpulsweb/lib/renderer.py (RepeatGroupRenderer.render_digest)
(RepeatGroupRenderer.get_field_info): Move the code that fetches
and parly formats description and value of a single digest field
into the new method get_field_info


Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog	2010-09-30 16:12:15 UTC (rev 3834)
+++ base/trunk/ChangeLog	2010-09-30 17:10:25 UTC (rev 3835)
@@ -1,5 +1,12 @@
 2010-09-30  Bernhard Herzog  <bh at intevation.de>
 
+	* mpulsweb/lib/renderer.py (RepeatGroupRenderer.render_digest)
+	(RepeatGroupRenderer.get_field_info): Move the code that fetches
+	and parly formats description and value of a single digest field
+	into the new method get_field_info
+
+2010-09-30  Bernhard Herzog  <bh at intevation.de>
+
 	* mpulsweb/lib/renderer.py: Fix formatting
 
 2010-09-30 Roland Geider <roland.geider at intevation.de>

Modified: base/trunk/mpulsweb/lib/renderer.py
===================================================================
--- base/trunk/mpulsweb/lib/renderer.py	2010-09-30 16:12:15 UTC (rev 3834)
+++ base/trunk/mpulsweb/lib/renderer.py	2010-09-30 17:10:25 UTC (rev 3835)
@@ -913,36 +913,22 @@
             out.append('<tr><td>%s</td></tr>' % escape(rg.getIdentifier()))
         else:
             child_identifier = rg.getChildren()[0].getIdentifier()
-            for num, field in enumerate(fields):
-                item = self.it.getItem('%s:%s:%s'
-                                       % (field, rg.getInternalIdentifier(),
-                                          case_id))
+            rg_identifier = rg.getInternalIdentifier()
+            for field in fields:
+                description, value = self.get_field_info(case_id, rg_identifier,
+                                                         field)
                 out.append('<tr>')
                 out.append('<td class="label">')
                 out.append(tag("a", href=url_for(controller="/navigation",
                                                  action="select_branch",
                                                  id=child_identifier)))
-                out.append(escape(self._getMeta(item).getDescription()))
+                out.append(escape(description))
                 out.append('</a>')
                 out.append('</td>')
                 out.append('<td>')
                 out.append(tag("a", href=url_for(controller="/navigation",
                                                  action="select_branch",
                                                  id=child_identifier)))
-                value = item.getValue()
-                if isinstance(self._getMeta(item), data.DateLeaf):
-                    value = format_date(value)
-                if isinstance(self._getMeta(item), data.ChoiceNode):
-                    childs = []
-                    for child in self._getMeta(item).getChildren():
-                        if isinstance(child, data.GroupNode):
-                            childs.extend(child.getChildren())
-                        else:
-                            childs.append(child)
-                    for child in childs:
-                        if str(child.getValue()) == str(value):
-                            value = child.getDescription()
-                            break
                 out.append('%s' % NA(value))
                 out.append('</a>')
                 out.append('</td>')
@@ -950,6 +936,27 @@
         out.append('</table>')
         return "".join(out)
 
+    def get_field_info(self, case_id, rg_identifier, field):
+        """Return description and formatted value for the given digest field"""
+        item = self.it.getItem('%s:%s:%s' % (field, rg_identifier, case_id))
+        meta = self._getMeta(item)
+        value = item.getValue()
+        if isinstance(meta, data.DateLeaf):
+            value = format_date(value)
+        if isinstance(meta, data.ChoiceNode):
+            childs = []
+            for child in meta.getChildren():
+                if isinstance(child, data.GroupNode):
+                    childs.extend(child.getChildren())
+                else:
+                    childs.append(child)
+            for child in childs:
+                if str(child.getValue()) == str(value):
+                    value = child.getDescription()
+                    break
+        return (meta.getDescription(), value)
+
+
     def render(self, showNext=False):
         out = []
         out.append('<div class="widget">')



More information about the Mpuls-commits mailing list