[Mpuls-commits] r1764 - in wasko/branches/2.0: . mpulsweb/lib
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed Feb 24 19:11:45 CET 2010
Author: bh
Date: 2010-02-24 19:11:44 +0100 (Wed, 24 Feb 2010)
New Revision: 1764
Modified:
wasko/branches/2.0/ChangeLog
wasko/branches/2.0/mpulsweb/lib/renderer.py
Log:
* mpulsweb/lib/renderer.py (ErrorRenderer.render_items): New
method to render error and warning items. This is a parameterized
version of duplicated code in ErrorRenderer.render
(ErrorRenderer.render): Use render_items to render errors and
warnings.
Modified: wasko/branches/2.0/ChangeLog
===================================================================
--- wasko/branches/2.0/ChangeLog 2010-02-24 18:09:23 UTC (rev 1763)
+++ wasko/branches/2.0/ChangeLog 2010-02-24 18:11:44 UTC (rev 1764)
@@ -1,5 +1,13 @@
2010-02-24 Bernhard Herzog <bh at intevation.de>
+ * mpulsweb/lib/renderer.py (ErrorRenderer.render_items): New
+ method to render error and warning items. This is a parameterized
+ version of duplicated code in ErrorRenderer.render
+ (ErrorRenderer.render): Use render_items to render errors and
+ warnings.
+
+2010-02-24 Bernhard Herzog <bh at intevation.de>
+
* mpulsweb/lib/renderer.py (ErrorRenderer.render): Remove unused
local variables.
Modified: wasko/branches/2.0/mpulsweb/lib/renderer.py
===================================================================
--- wasko/branches/2.0/mpulsweb/lib/renderer.py 2010-02-24 18:09:23 UTC (rev 1763)
+++ wasko/branches/2.0/mpulsweb/lib/renderer.py 2010-02-24 18:11:44 UTC (rev 1764)
@@ -913,54 +913,41 @@
tree = page.getInstanceTree()
out = []
+ out.append(self.render_items(self.error_items, _('Formular errors'),
+ "/images/alert.png", tree))
+ out.append(self.render_items(self.warnings, _('Formular warnings'),
+ "/images/info.png", tree))
+ return "".join(out)
- if self.error_items:
- out.append('<div class="widget dialog">')
- out.append('<h1><img src="/images/alert.png">%s</h1>'
- % escape(_('Formular errors')))
- out.append('<ol>')
+ def render_items(self, items, title, icon, tree):
+ if not items:
+ return ""
- for k, v in self.error_items.iteritems():
- element = tree.getFormEd().findByName(k.split(':')[0])
- description = element.getDescription()
- out.append('<li>')
- out.append(tag("a", href="/formularpage/undo/%s" % k))
- out.append(tag("img", src="/images/icons/formular/undo.png",
- border="0", alt="undo",
- title=_('Restore last valid value'),
- _close=True))
- out.append('</a>')
- out.append(tag("a", class_="error", href="#f_%s" % k))
- out.append("%s: %s" % (escape(description), escape(v)))
- out.append("</a>")
- out.append("</li>")
+ out = []
+ out.append('<div class="widget dialog">')
+ out.append('<h1>')
+ out.append(tag("img", src=icon))
+ out.append(escape(_('Formular warnings')))
+ out.append('</h1>')
+ out.append('<ol>')
- out.append('</ol>')
- out.append('</div>')
+ for k, v in items.iteritems():
+ element = tree.getFormEd().findByName(k.split(':')[0])
+ description = element.getDescription()
+ out.append('<li>')
+ out.append(tag("a", href="/formularpage/undo/%s" % k))
+ out.append(tag("img", src="/images/icons/formular/undo.png",
+ border="0", alt="undo",
+ title=_('Restore last valid value'),
+ _close=True))
+ out.append('</a>')
+ out.append(tag("a", class_="error", href="#f_%s" % k))
+ out.append("%s: %s" % (escape(description), escape(v)))
+ out.append("</a>")
+ out.append("</li>")
- if self.warnings:
- out.append('<div class="widget dialog">')
- out.append('<h1><img src="/images/info.png">%s</h1>'
- % escape(_('Formular warnings')))
- out.append('<ol>')
-
- for k, v in self.warnings.iteritems():
- element = tree.getFormEd().findByName(k.split(':')[0])
- description = element.getDescription()
- out.append('<li>')
- out.append(tag("a", href="/formularpage/undo/%s" % k))
- out.append(tag("img", src="/images/icons/formular/undo.png",
- border="0", alt="undo",
- title=_('Restore last valid value'),
- _close=True))
- out.append('</a>')
- out.append(tag("a", class_="error", href="#f_%s" % k))
- out.append("%s: %s" % (escape(description), escape(v)))
- out.append("</a>")
- out.append("</li>")
-
- out.append('</ol>')
- out.append('</div>')
+ out.append('</ol>')
+ out.append('</div>')
return "".join(out)
More information about the Mpuls-commits
mailing list