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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Jul 30 14:15:32 CEST 2010


Author: torsten
Date: 2010-07-30 14:15:31 +0200 (Fri, 30 Jul 2010)
New Revision: 3279

Modified:
   base/trunk/mpulsweb/controllers/case_overview.py
Log:
* mpulsweb/controllers/case_overview.py (get_sort): Issue860: Return
either userdefind, session-saved, or default sort options (in that
order). Save returned sort order for next call.


Modified: base/trunk/mpulsweb/controllers/case_overview.py
===================================================================
--- base/trunk/mpulsweb/controllers/case_overview.py	2010-07-29 14:58:49 UTC (rev 3278)
+++ base/trunk/mpulsweb/controllers/case_overview.py	2010-07-30 12:15:31 UTC (rev 3279)
@@ -23,8 +23,19 @@
 
 
 def get_sort(params):
-    sort = params.get('sort_field', FORM_DEFAULTS_SORT)
-    order = params.get('sort_order', FORM_DEFAULTS_ORDER)
+    '''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.
+    '''
+    sort = params.get('sort_field', 
+                      session['CASE_OVERVIEW_SEARCHOPTIONS'].get('sort_field', 
+                      FORM_DEFAULTS_SORT))
+    order = params.get('sort_order', 
+                      session['CASE_OVERVIEW_SEARCHOPTIONS'].get('sort_order',
+                      FORM_DEFAULTS_ORDER))
+    session['CASE_OVERVIEW_SEARCHOPTIONS']['sort_field'] = sort 
+    session['CASE_OVERVIEW_SEARCHOPTIONS']['sort_order'] = order
+    session.save()
     return sort, order
 
 def default_phases():
@@ -112,6 +123,7 @@
             session['CASE_OVERVIEW_SEARCHOPTIONS'] = {}
             session['CASE_OVERVIEW_SELECTION'] = {}
             session['EXTENDED_SEARCH'] = False
+            session['CASE_OVERVIEW_SEARCHOPTIONS'] = {}
             session.save()
 
         form_defaults = (session.get('CASE_OVERVIEW_SEARCHOPTIONS')
@@ -182,9 +194,9 @@
         sort_field, sort_order = get_sort(options)
         
         # Pass the sort options to the template
-        c.sort_field = sort_field
+        c.sort_field = sort_field 
         c.sort_order = sort_order
-        
+
         # default behavior is to take the sortfield for sorting
         search_options.append('sort_field:%s' % sort_field)
         search_options.append('sort_order:%s' % sort_order)



More information about the Mpuls-commits mailing list