[Mpuls-commits] r4655 - base/trunk/mpulsweb/controllers

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Feb 18 16:22:23 CET 2011


Author: torsten
Date: 2011-02-18 16:22:23 +0100 (Fri, 18 Feb 2011)
New Revision: 4655

Modified:
   base/trunk/mpulsweb/controllers/case_overview.py
Log:
* mpulsweb/controllers/case_overview.py
	(CaseOverviewController.overview): Do not use CaseOverviewForm
	validator. Reactive get_sort function.


Modified: base/trunk/mpulsweb/controllers/case_overview.py
===================================================================
--- base/trunk/mpulsweb/controllers/case_overview.py	2011-02-18 14:48:14 UTC (rev 4654)
+++ base/trunk/mpulsweb/controllers/case_overview.py	2011-02-18 15:22:23 UTC (rev 4655)
@@ -17,24 +17,24 @@
 log = logging.getLogger(__name__)
 
 
-#def get_sort(params):
-#    '''Return sort field and sort order. First try to return a userdefined sort
-#    and order. If user does not provide one of there params, try to return the
-#    safed params in session. If session is also empty return default params.
-#    '''
-#    session_options = session['CASE_OVERVIEW_SEARCHOPTIONS']
-#    sort = params.get('sort_field',
-#                      session_options.get('sort_field',
-#                                          g.mpuls_config.get('search',
-#                                                            'default-sorting')))
-#    order = params.get('sort_order',
-#                       session_options.get('sort_order',
-#                                           g.mpuls_config.get('search',
-#                                                              'default-order')))
-#    session_options['sort_field'] = sort
-#    session_options['sort_order'] = order
-#    session.save()
-#    return sort, order
+def get_sort(params):
+    '''Return sort field and sort order. First try to return a userdefined sort
+    and order. If user does not provide one of there params, try to return the
+    safed params in session. If session is also empty return default params.
+    '''
+    session_options = session.get('CASE_OVERVIEW_SEARCHOPTIONS', {})
+    sort = params.get('sort_field',
+                      session_options.get('sort_field',
+                                          g.mpuls_config.get('search',
+                                                            'default-sorting')))
+    order = params.get('sort_order',
+                       session_options.get('sort_order',
+                                           g.mpuls_config.get('search',
+                                                              'default-order')))
+    session_options['sort_field'] = sort
+    session_options['sort_order'] = order
+    session.save()
+    return sort, order
 
 # TODO: Move function. Is only used in other controllers. May be better placed
 # in Model phase or helpers?
@@ -94,17 +94,17 @@
 
         # Get saved search params from session.
         search_options = search_options_from_session()
-        # Update searchparams with
-        validator = CaseOverviewForm()
-        search_options.update(validator.to_python(request.params))
-
+        # Update search options with ordering
+        sort, order = get_sort(request.params) 
+        search_options['sort_order'] = order
+        search_options['sort_field'] = sort 
         session['CASE_OVERVIEW_SEARCHOPTIONS'] = search_options
         session.save()
-        print g.case
         return self.search(search_options)
 
     def _getCaseList(self, search_options):
         cases = MpulsCaseOverview()
+        print search_options
         if search_options:
             options = self.parseSearchOptions(search_options,
                                         extended=session.get("EXTENDED_SEARCH"))



More information about the Mpuls-commits mailing list