[Mpuls-commits] r281 - in wasko/trunk: . waskaweb/controllers waskaweb/lib waskaweb/model waskaweb/templates waskaweb/templates/casemanagement

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Sun Feb 22 21:44:32 CET 2009


Author: teichmann
Date: 2009-02-22 21:44:15 +0100 (Sun, 22 Feb 2009)
New Revision: 281

Modified:
   wasko/trunk/ChangeLog.txt
   wasko/trunk/waskaweb/controllers/case.py
   wasko/trunk/waskaweb/lib/helpers.py
   wasko/trunk/waskaweb/lib/renderer.py
   wasko/trunk/waskaweb/model/navigation.py
   wasko/trunk/waskaweb/templates/casemanagement/formular.mako
   wasko/trunk/waskaweb/templates/main.mako
Log:
Make "Speichern und Weiter" work again.



Modified: wasko/trunk/ChangeLog.txt
===================================================================
--- wasko/trunk/ChangeLog.txt	2009-02-22 16:45:40 UTC (rev 280)
+++ wasko/trunk/ChangeLog.txt	2009-02-22 20:44:15 UTC (rev 281)
@@ -1,5 +1,27 @@
 2009-02-22	Sascha L. Teichmann <teichmann at intevation.de>
 
+	Make "Speichern und Weiter" work again.
+
+	* waskaweb/templates/main.mako: Fixed span tag in status field.
+	  WASKO may need that fix, too.
+
+	* waskaweb/templates/casemanagement/formular.mako: removed
+	  'A' in HTML output.
+
+	* waskaweb/lib/renderer.py: Fixed submit tag in form.
+
+	* waskaweb/lib/helpers.py: new helper for figure out if 
+	  there are errors on page.
+
+	* waskaweb/controllers/case.py: Make "Speichern und weiter" 
+	  work again.
+
+	* waskaweb/model/navigation.py: removed needless code and
+	  chain pages to make it easier to find next page.
+
+	* 
+2009-02-22	Sascha L. Teichmann <teichmann at intevation.de>
+
 	* waskaweb/model/navigation.py: Fixed HTML rendering bug.
 	  TODO: Offline client needs this fix, too.
 

Modified: wasko/trunk/waskaweb/controllers/case.py
===================================================================
--- wasko/trunk/waskaweb/controllers/case.py	2009-02-22 16:45:40 UTC (rev 280)
+++ wasko/trunk/waskaweb/controllers/case.py	2009-02-22 20:44:15 UTC (rev 281)
@@ -429,14 +429,12 @@
         session.save()
 
         # Only proceed to next page if the page does not contain errors
-        if request.params.get('__formular_next') and len(h.getFormularErrors(ti.page)) <= 0:
-
-            nkey = ti.nextKey()
-            if not nkey is None:
-                nti = self.getNavigation().getTreeItem(nkey)
-                if not nti is None:
-                    ti = nti
-                    ti.showPath()
+        if request.params.get('__formular_next') \
+            and not h.hasErrorsOnPage(case_session.page_id):
+            nti = ti.nextKey()
+            if not nti is None:
+                ti = nti
+                ti.unfold()
         return self.edit(ds_id, ti.key) 
 
     def __save(self, pageName, params, old_errors, ds_id):

Modified: wasko/trunk/waskaweb/lib/helpers.py
===================================================================
--- wasko/trunk/waskaweb/lib/helpers.py	2009-02-22 16:45:40 UTC (rev 280)
+++ wasko/trunk/waskaweb/lib/helpers.py	2009-02-22 20:44:15 UTC (rev 281)
@@ -41,6 +41,8 @@
 from waskaweb.lib.renderer  import ErrorRenderer
 from waskaweb.lib.filecache import FileCache
 
+#from types import IntType
+
 from waskaweb.model.data    import PageNode
 
 VALID_DATE = re.compile(r'^([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})$')
@@ -178,7 +180,22 @@
     if not m: return None
     return datetime.timedelta(hours = int(m.group(1)), minutes = int(m.group(2)))
 
+def hasErrorsOnPage(case, page_id):
+    case       = session.get('case')
+    navigation = session.get('navigation.tree')
+    if not navigation or not case: return False
+    errors = case.getFormErrors()
+    tree_item = navigation.getTreeItem(page_id)
+    if not tree_item: return False
+    name = tree_item.name
+    for error in errors.itervalues():
+        if error.page == name:
+            return True
+    return False
+    
+
 def getFormularHeaders(page_id):
+    #if type(page_id) != IntType: return u""
     navigation = session.get('navigation.tree')
     if not navigation: return u""
     tree_item = navigation.getTreeItem(page_id)
@@ -201,6 +218,7 @@
         pass
 
 def getErrorsAndWarningsOnPage(page_id):
+    #if type(page_id) != IntType: return u""
     case = session.get('case')
     if not case: return ""
     navigation = session.get('navigation.tree')

Modified: wasko/trunk/waskaweb/lib/renderer.py
===================================================================
--- wasko/trunk/waskaweb/lib/renderer.py	2009-02-22 16:45:40 UTC (rev 280)
+++ wasko/trunk/waskaweb/lib/renderer.py	2009-02-22 20:44:15 UTC (rev 281)
@@ -288,10 +288,10 @@
             out.append('<form id="waska_form" action="/case/save" accept-charset="UTF-8" method="POST">\n')
             # Add submitbutton at the top of the page too
             out.append('<div class="waska_form_element w100">')
-            out.append('<input type="hidden" name="ds" value="%s"' % ds_id)
+            out.append('<input type="hidden" name="ds" value="%s">' % ds_id)
             out.append('<input type="submit" value="&Uuml;bernehmen">\n')
             if showNext:
-                out.append('<input type="submit" value="&Uuml;bernehmen und weiter">\n')
+                out.append('<input type="submit" value="&Uuml;bernehmen und weiter" name="__formular_next">\n')
             out.append('</div>')
 
         self.stateStack = []
@@ -306,9 +306,9 @@
                 out.append('<input type="hidden" name="page" value="%s">\n' \
                     % escape(name, True))
             out.append('<div class="waska_form_element w100">')
-            out.append('<input type="submit" value="&Uuml;bernehmen"\n')
+            out.append('<input type="submit" value="&Uuml;bernehmen">\n')
             if showNext:
-                out.append('<input type="submit" value="&Uuml;bernehmen und weiter")>\n')
+                out.append('<input type="submit" value="&Uuml;bernehmen und weiter" name="__formular_next">\n')
             out.append('</div>')
             out.append('</form>\n')
 

Modified: wasko/trunk/waskaweb/model/navigation.py
===================================================================
--- wasko/trunk/waskaweb/model/navigation.py	2009-02-22 16:45:40 UTC (rev 280)
+++ wasko/trunk/waskaweb/model/navigation.py	2009-02-22 20:44:15 UTC (rev 281)
@@ -51,6 +51,7 @@
         self.parent      = parent
         self.children    = children
         self.key         = None
+        self.next        = None
 
     def is_child(self):
         return self.children is None
@@ -61,6 +62,13 @@
             cur = cur.children[0]
         return cur
 
+    def find_page(self):
+        cur = self
+        while cur:
+            if cur.next: return cur
+            cur = cur.parent
+        return None
+
     def unfold(self):
         cur = self
         while cur:
@@ -167,25 +175,10 @@
         return u"".join(out)
 
     def nextKey(self):
-        n_key = self.key + 1
-        root = self
-        while root.parent:
-            root = root.parent
-        stack = root.children[:]
-        while stack:
-            item = stack.pop()
-            if item.key == n_key:
-                return n_key
-            if item.children:
-                stack.extend(item.children)
-        return None
+        page = self.find_page()
+        if not page: return None
+        return page.next
 
-    def showPath(self):
-        current = self
-        while current:
-            current.displayChildren = True
-            current = current.parent
-
 def get_page(nc):
     while nc:
         if isinstance(nc, PageNode):
@@ -196,8 +189,9 @@
 class NavigationTreeBuilder(object):
 
     def __init__(self, formed):
-        self.key  = 0
-        self.root = self.build(formed, None)
+        self.key   = 0
+        self.prev  = None
+        self.root  = self.build(formed, None)
 
     def build(self, nc, parent):
 
@@ -205,6 +199,9 @@
             if nc.isInvisible():
                 return None
             ti = TreeItem(nc.getName(), nc.getDescription(), parent = parent)
+            if self.prev:
+                self.prev.next = ti
+            self.prev = ti
             ti.key = self.key
             self.key += 1
             return ti
@@ -268,14 +265,6 @@
                     stack.append(c.children)
         return None
 
-    def getTreeItemByPageName(self, name):
-        '''Returns the treeitem which will be actually rendered when clicking
-        on the item in navigation tree. This is the last treeitem in the tree
-        with the given name'''
-        item = self.findTreeItemByPageName(name)
-        if not item: raise HTTPNotFound()
-        return item
-
     def render(self, page, file_cache, error_pages = set()):
         error_lookup = set()
         self.root.build_error_lookup(error_lookup, error_pages)

Modified: wasko/trunk/waskaweb/templates/casemanagement/formular.mako
===================================================================
--- wasko/trunk/waskaweb/templates/casemanagement/formular.mako	2009-02-22 16:45:40 UTC (rev 280)
+++ wasko/trunk/waskaweb/templates/casemanagement/formular.mako	2009-02-22 20:44:15 UTC (rev 281)
@@ -35,7 +35,7 @@
 	<li><a href="/case/${session.get('case').getMode()}/${c.ds_id}/${c.page_id}" onclick="return checkModification();">${h.getFormularName(c.page_id)}</a></li>
 </%def>
 
-<%def name="buildFormErrors()">A
+<%def name="buildFormErrors()">
     ${h.getErrorsAndWarningsOnPage(c.page_id)}
 </%def>
 

Modified: wasko/trunk/waskaweb/templates/main.mako
===================================================================
--- wasko/trunk/waskaweb/templates/main.mako	2009-02-22 16:45:40 UTC (rev 280)
+++ wasko/trunk/waskaweb/templates/main.mako	2009-02-22 20:44:15 UTC (rev 281)
@@ -197,7 +197,7 @@
       <div id="content" class="right">
         <div id="status_str_nofloat">
           % if c.status_msg:
-            <span class="redcolor">${c.status_msg}<span>
+            <span class="redcolor">${c.status_msg}</span>
           % else:
             <strong>Hinweis:</strong> Nach 30 Minuten ohne Aktivität/ohne Speichern wird die Sitzung
       automatisch beendet, ggf. gehen Daten verloren!



More information about the Mpuls-commits mailing list