[Mpuls-commits] r385 - in wasko/trunk: . waskaweb/lib waskaweb/model waskaweb/templates/caselifetime

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Mar 17 18:39:38 CET 2009


Author: teichmann
Date: 2009-03-17 18:39:34 +0100 (Tue, 17 Mar 2009)
New Revision: 385

Modified:
   wasko/trunk/ChangeLog.txt
   wasko/trunk/waskaweb/lib/helpers.py
   wasko/trunk/waskaweb/model/casedocument.py
   wasko/trunk/waskaweb/templates/caselifetime/overview.mako
Log:
Added support for marking errors on 'Verwaltungs' page.


Modified: wasko/trunk/ChangeLog.txt
===================================================================
--- wasko/trunk/ChangeLog.txt	2009-03-17 16:59:46 UTC (rev 384)
+++ wasko/trunk/ChangeLog.txt	2009-03-17 17:39:34 UTC (rev 385)
@@ -1,5 +1,18 @@
 2009-03-17	Sascha L. Teichmann	<teichmann at intevation.de>
 
+	* waskaweb/lib/helpers.py: new function toErrorDicts() which takes an 
+	  error list from DataSaveException and returns a tuple (form_result, form_errors)
+	  suitable for formencode to refill the form.
+
+	* waskaweb/model/casedocument.py: added method getDescription() to
+	  to return the description for a given widget name. If not found it
+	  returns the given name.
+
+	* waskaweb/templates/caselifetime/overview.mako: use getDescription()
+	  to show the right description for a erroneous field.
+
+2009-03-17	Sascha L. Teichmann	<teichmann at intevation.de>
+
 	* waskaweb/model/casedocument.py: Error are now report in form
 	  of lists of tuples (<name of item>, <invalid value from web>, <error desc>).
 	  setData() has now a 'do_write' parameter (default: True). when set

Modified: wasko/trunk/waskaweb/lib/helpers.py
===================================================================
--- wasko/trunk/waskaweb/lib/helpers.py	2009-03-17 16:59:46 UTC (rev 384)
+++ wasko/trunk/waskaweb/lib/helpers.py	2009-03-17 17:39:34 UTC (rev 385)
@@ -123,7 +123,20 @@
     value = value.replace('\r', '<br>')
     return value
 
+def toErrorDicts(error_list):
+    values, errors = {}, {}
 
+    for key, value, error in error_list:
+        values[key] = value
+        try:
+            old = errors[key]
+            errors[key] = u"%s, %s" % (old, error)
+        except KeyError:
+            errors[key] = error
+
+    return values, errors
+
+
 def dd_mm_YYYY(d, empty = ''):
     ''' datetime.strftime() dislikes years before 1900. '''
     if d is None: return empty

Modified: wasko/trunk/waskaweb/model/casedocument.py
===================================================================
--- wasko/trunk/waskaweb/model/casedocument.py	2009-03-17 16:59:46 UTC (rev 384)
+++ wasko/trunk/waskaweb/model/casedocument.py	2009-03-17 17:39:34 UTC (rev 385)
@@ -425,4 +425,10 @@
                     ps.setData(k, v)
                 ps.store()
 
+    def getDescription(self, name):
+        try:
+            return self.widgets[name].getDescription()
+        except KeyError:
+            return name
+
 # vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

Modified: wasko/trunk/waskaweb/templates/caselifetime/overview.mako
===================================================================
--- wasko/trunk/waskaweb/templates/caselifetime/overview.mako	2009-03-17 16:59:46 UTC (rev 384)
+++ wasko/trunk/waskaweb/templates/caselifetime/overview.mako	2009-03-17 17:39:34 UTC (rev 385)
@@ -19,7 +19,7 @@
     <h1><a name="error_list">Fehlerhafte Formulareingabe</a></h1>
     <ul>
     % for key, err in c.form_errors.iteritems():
-      <li>${key}: ${err}</li>
+      <li><a href="#${key}">${g.formedTree.getDescription(key) | h}</a>: ${err | h}</li>
     % endfor
     </ul>
   </div>



More information about the Mpuls-commits mailing list