[Mpuls-commits] r5327 - base/trunk/mpulsweb/lib
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed Sep 14 13:07:18 CEST 2011
Author: ludwig
Date: 2011-09-14 13:07:18 +0200 (Wed, 14 Sep 2011)
New Revision: 5327
Modified:
base/trunk/mpulsweb/lib/navigation.py
Log:
Issue 967: icons in the structure part of a page, if an error occurs.
Calculate error_pages with uncommited_fields, add a dict which maps
from field to page in the navigatortree.
And changed error display to an alert icon.
Modified: base/trunk/mpulsweb/lib/navigation.py
===================================================================
--- base/trunk/mpulsweb/lib/navigation.py 2011-09-14 06:54:18 UTC (rev 5326)
+++ base/trunk/mpulsweb/lib/navigation.py 2011-09-14 11:07:18 UTC (rev 5327)
@@ -33,9 +33,9 @@
from pylons import g
-from formed.meta.data import PageNode
+from formed.meta.data import PageNode, Leaf, RadioNode, Node
from formed.instance.tree import InstanceNode, RepeatInstanceContainerNode, \
- RepeatInstanceNode
+ RepeatInstanceNode, IDENTIFIER_SEPARATOR
from formed.instance.backends.postgres import DBFactory as InstanceFactory
from mpulsweb.lib.translation import _
@@ -80,6 +80,12 @@
def render_navigation(mode="r"):
tree = session['navigation.tree']
error_pages = set()
+ for fieldandnr in session.get('uncommited_fields', []):
+ error_field = fieldandnr.split(IDENTIFIER_SEPARATOR, 1)[0]
+ error_page = tree.field2page.get(error_field, "")
+ if error_page:
+ error_pages.add(error_page)
+
return tree.render(tree.root, FileCache(), error_pages)
def mark_folderopen(ti):
@@ -231,7 +237,13 @@
# Error marking
out.append(u'<td class="%s">' % selected)
if has_error:
- out.append('<span class="error">E</span>')
+ out.append('<span class="error">' +
+ get_image("/images/icons/info/alert.png",
+ u' border="0"'
+ u' alt="E"'
+ u' width="16"'
+ u' height="16"')
+ + '</span>')
out.append(u'</td>')
out.append(u'</tr>')
@@ -276,6 +288,8 @@
self.first = None
self.openfolders = openfolders or []
self.root = self.build(root, None)
+ self.field2page = {}
+ self.build_dict(root, "")
def build(self, nc, parent):
if isinstance(nc, RepeatInstanceNode):
@@ -318,12 +332,25 @@
ti.key = nc.getIdentifier()
return ti
+ def build_dict(self, nc, page_name):
+ meta = nc.getMeta()
+ if isinstance(meta, PageNode):
+ page_name = meta.getName()
+ elif isinstance(meta, RadioNode):
+ self.field2page[meta.getName()] = page_name
+ elif isinstance(meta, Leaf):
+ self.field2page[meta.getName()] = page_name
+
+ if isinstance(nc, InstanceNode):
+ for child in nc.getChildren():
+ self.build_dict(child, page_name)
class NavigationTree:
def __init__(self, instance, openfolders=None):
builder = NavigationTreeBuilder(instance.getRootNode(), openfolders)
self.root = builder.root
+ self.field2page = builder.field2page
self.first_page = builder.first
def getAllItems(self):
More information about the Mpuls-commits
mailing list