[Mpuls-commits] r3338 - in base/trunk: . mpulsweb/controllers mpulsweb/lib mpulsweb/templates/casemanagement

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Aug 6 16:44:36 CEST 2010


Author: roland
Date: 2010-08-06 16:44:34 +0200 (Fri, 06 Aug 2010)
New Revision: 3338

Modified:
   base/trunk/ChangeLog
   base/trunk/mpulsweb/controllers/case_overview.py
   base/trunk/mpulsweb/lib/validators.py
   base/trunk/mpulsweb/templates/casemanagement/search.mako
Log:
issue907: added date fields to case search

Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog	2010-08-06 13:41:15 UTC (rev 3337)
+++ base/trunk/ChangeLog	2010-08-06 14:44:34 UTC (rev 3338)
@@ -1,5 +1,13 @@
-2010-07-12  Roland Geider  <roland.geider at intevation.de>
+2010-08-06  Roland Geider  <roland.geider at intevation.de>
 
+	* mpulsweb/controllers/case_overview.py,
+	  mpulsweb/lib/validators.py,
+	  mpulsweb/templates/casemanagement/search.mako: issue907: added date
+	  fields to case search
+
+
+2010-08-06  Roland Geider  <roland.geider at intevation.de>
+
 	* mpulsweb/templates/casemanagement/caselist.mako: issue879: use
 	  url_for for the icons in the case legend
 

Modified: base/trunk/mpulsweb/controllers/case_overview.py
===================================================================
--- base/trunk/mpulsweb/controllers/case_overview.py	2010-08-06 13:41:15 UTC (rev 3337)
+++ base/trunk/mpulsweb/controllers/case_overview.py	2010-08-06 14:44:34 UTC (rev 3338)
@@ -130,13 +130,19 @@
         session['CASE_OVERVIEW_SEARCHOPTIONS'] = form_defaults
         session.save()
         search_options = self.parseSearchOptions(form_defaults)
-        # Sorting of the cases
+        
+        # Sorting the cases
         search_options.extend(self.parseSortOptions(request.params))
         search_str = ";".join(search_options)
 
-        # Do search
+
+        if not c.form_errors:
+            c.form_errors = {}
+        
+        # Do the search if there are no errors
         c.cases = MpulsCaseOverview()
-        c.cases.search(search_str)
+        if not c.form_errors:
+            c.cases.search(search_str)
 
         # Values used in the template
         #
@@ -169,22 +175,32 @@
             c.hide_evaluation = True
 
         overview = render('/casemanagement/overview.mako')
+        
+        formular_defaults = form_defaults_copy or request.params.mixed()
         return formencode.htmlfill.render(overview,
-                                          defaults=form_defaults_copy)
+                                          defaults=formular_defaults)
 
 
     @checkRole(('admin', 'cm', 'pt_dlr'))
     def search(self):
-        validator = SearchCaseForm()
-        c.form_result = {}
-        c.form_errors = {}
+        validator      = SearchCaseForm()
+        c.form_result  = {}
+        c.form_errors  = {}
         try:
-            form_result = validator.to_python(request.params)
+            c.form_result = validator.to_python(request.params)
         except formencode.Invalid, error:
-            log.exception(error)
-            form_result = error.value
-            form_errors = error.error_dict or {}
-        session['CASE_OVERVIEW_SEARCHOPTIONS'] = form_result
+            log.exception("search: formencode error %s" % error)
+            c.form_result = error.value
+            c.form_errors = error.error_dict or {}
+
+        # Dont save in the session values with errors
+        if c.form_errors != {}:
+            form_results_copy = c.form_result.copy()
+            for key in form_results_copy:
+                if key in c.form_errors:
+                    c.form_result.pop(key)
+        
+        session['CASE_OVERVIEW_SEARCHOPTIONS'] = c.form_result
         session.save()
         return self.overview()
 

Modified: base/trunk/mpulsweb/lib/validators.py
===================================================================
--- base/trunk/mpulsweb/lib/validators.py	2010-08-06 13:41:15 UTC (rev 3337)
+++ base/trunk/mpulsweb/lib/validators.py	2010-08-06 14:44:34 UTC (rev 3338)
@@ -661,8 +661,8 @@
     standin = Int(if_missing=0)
     editor = Int(if_missing=-1)
     phase = ForEach(String(), convert_to_list=True)
-    #sdate = String()
-    #edate = String()
+    sdate = DateCheck()
+    edate = DateCheck()
     cm_state = Int(if_missing=None)
 
 

Modified: base/trunk/mpulsweb/templates/casemanagement/search.mako
===================================================================
--- base/trunk/mpulsweb/templates/casemanagement/search.mako	2010-08-06 13:41:15 UTC (rev 3337)
+++ base/trunk/mpulsweb/templates/casemanagement/search.mako	2010-08-06 14:44:34 UTC (rev 3338)
@@ -77,18 +77,18 @@
           % endfor
         </td>
       </tr>
-      ##<tr style="${not c.extended_search and 'display:none' or ''}">
-      ##  <td class="label">${_('Start date')}</td>
-      ##  <td>
-      ##    <input type="text" name="sdate" value="">
-      ##  </td>
-      ##</tr>
-      ##<tr style="${not c.extended_search and 'display:none' or ''}">
-      ##  <td class="label">${_('End date')}</td>
-      ##  <td>
-      ##    <input type="text" name="edate" value="">
-      ##  </td>
-      ##</tr>
+      <tr style="${not c.extended_search and 'display:none' or ''}">
+        <td class="label">${_('Start date')}</td>
+        <td>
+          <input type="text" name="sdate" value="">
+        </td>
+      </tr>
+      <tr style="${not c.extended_search and 'display:none' or ''}">
+        <td class="label">${_('End date')}</td>
+        <td>
+          <input type="text" name="edate" value="">
+        </td>
+      </tr>
       <tr>
         <td class=""></td>
         <td></td>



More information about the Mpuls-commits mailing list