[Mpuls-commits] r5409 - in base/trunk/mpulsweb: controllers lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Oct 6 11:39:51 CEST 2011


Author: ludwig
Date: 2011-10-06 11:39:50 +0200 (Thu, 06 Oct 2011)
New Revision: 5409

Modified:
   base/trunk/mpulsweb/controllers/formularpage.py
   base/trunk/mpulsweb/lib/formedrenderer.py
Log:
Issue 2188 Changed the html rendering for print formular.
Substitute fieldset with table and legend with th.
It no longer cuts groups in the printout.


Modified: base/trunk/mpulsweb/controllers/formularpage.py
===================================================================
--- base/trunk/mpulsweb/controllers/formularpage.py	2011-10-05 18:39:05 UTC (rev 5408)
+++ base/trunk/mpulsweb/controllers/formularpage.py	2011-10-06 09:39:50 UTC (rev 5409)
@@ -20,7 +20,7 @@
 from mpulsweb.lib.helpers import url_for, literal
 from mpulsweb.model.phase import PhaseFactory, PC_MANUAL, PC_FULLAUTO
 
-from mpulsweb.lib.formedrenderer import ViewRenderer, UrlFactory
+from mpulsweb.lib.formedrenderer import ViewPrintRenderer, UrlFactory
 
 
 log = logging.getLogger(__name__)
@@ -79,7 +79,7 @@
         errors, defaults = convert_error_items(page.getErrors())
         formdata = TreeFormData(instance_tree, shadow=defaults, errors=errors,
                                 node=page)
-        renderer = ViewRenderer(formdata, page.getMeta(), url_factory,
+        renderer = ViewPrintRenderer(formdata, page.getMeta(), url_factory,
                                 **renderer_kw_args)
 
     navigation_item = session['navigation.tree'].getTreeItem(id)

Modified: base/trunk/mpulsweb/lib/formedrenderer.py
===================================================================
--- base/trunk/mpulsweb/lib/formedrenderer.py	2011-10-05 18:39:05 UTC (rev 5408)
+++ base/trunk/mpulsweb/lib/formedrenderer.py	2011-10-06 09:39:50 UTC (rev 5409)
@@ -29,7 +29,8 @@
 #
 
 from formed.renderer.html import HtmlRenderer, UrlFactory as BaseUrlFactory
-from formed.renderer.helpers import tag
+from formed.renderer.html import RendererContext, Container, Item
+from formed.renderer.helpers import tag, escape
 
 from mpulsweb.lib.helpers import url_for
 
@@ -56,3 +57,39 @@
             return ("warning", messages)
 
         return ("", [])
+
+class ViewPrintRenderer(ViewRenderer):
+
+    def render_group(self, context, nc):
+        description = nc.getDescription()
+
+        out = []
+        if nc.isInvisible():
+            if description:
+                out.append("<!-- %s -->\n" % escape(description))
+        else:
+            out.append("<table border=\"1\">\n")
+            if description:
+                out.append("<th>%s %s</th>\n"
+                           % ("".join(self.render_label(context, nc,
+                                                        self.data.get_id(nc),
+                                                        False)),
+                              "".join(self.render_annotation_links(nc))))
+            out.append("<tr><td>\n")
+            out.append(self.render_children(RendererContext(nc, Container), nc))
+            out.append("</td></tr></table>\n")
+        return Item("".join(out))
+
+    def render_inline_repeat_group(self, context, nc):
+        description = nc.getDescription()
+        out = []
+        out.append('<table border=\"1\">')
+        out.append('<th>%s %s</th>'
+                   % (escape(description),
+                      "".join(self.render_annotation_links(nc))))
+        out.append('<tr><td>')
+        out.append('<table class="repeatgroup">')
+        out.extend(self.render_repeat_list(context, nc))
+        out.append('</table>')
+        out.append('</td></tr></table>')
+        return Item("".join(out))



More information about the Mpuls-commits mailing list