mango r277 - in branches/django: . mango



Author: ovitters
Date: Sun Jun 29 00:21:39 2008
New Revision: 277
URL: http://svn.gnome.org/viewvc/mango?rev=277&view=rev

Log:
	* mango/views.py (setup_filter, list_users, list_accounts,
	  list_mirrors, list_foundationmembers, list_modules): Remember the
	  used filters within the session data.


Modified:
   branches/django/   (props changed)
   branches/django/ChangeLog
   branches/django/mango/views.py

Modified: branches/django/mango/views.py
==============================================================================
--- branches/django/mango/views.py	(original)
+++ branches/django/mango/views.py	Sun Jun 29 00:21:39 2008
@@ -76,12 +76,17 @@
 
     return page
 
-def setup_filter(pagenode, values, filters):
+def setup_filter(pagenode, request, filters):
     filter = None
     filternode = None
 
     for key, val in filters.items():
-        filter_value = values.get('filter_%s' % key, '')
+        key_get = 'filter_%s' % key
+        key_session = 'filter_%s_%s' % (pagenode.tag, key)
+        if key_get in request.GET:
+            filter_value = request.GET.get(key_get, '')
+        else:
+            filter_value = request.session.get(key_session, '')
         if not filter_value:
             continue
 
@@ -101,6 +106,7 @@
         if not filternode:
             filternode = ET.SubElement(pagenode, 'filter')
         ET.SubElement(filternode, key).text = filter_value
+        request.session[key_session] = filter_value
 
     return filter
 
@@ -123,7 +129,7 @@
 def list_users(request):
     doc, pagenode = get_xmldoc('List Users', request, 'listusers')
 
-    filter = setup_filter(pagenode, request.GET, {
+    filter = setup_filter(pagenode, request, {
         'keyword': lambda keyword: Q(uid__contains=keyword) | Q(cn__contains=keyword) | Q(mail__contains=keyword)
     })
 
@@ -172,7 +178,7 @@
 def list_accounts(request):
     doc, pagenode = get_xmldoc('List Accounts', request, 'listaccounts')
 
-    filter = setup_filter(pagenode, request.GET, {
+    filter = setup_filter(pagenode, request, {
         'keyword': lambda keyword: Q(uid__contains=keyword) | Q(cn__contains=keyword) | Q(mail__contains=keyword),
         'status': lambda keyword: Q(status=keyword)
     })
@@ -218,7 +224,7 @@
 def list_mirrors(request):
     doc, pagenode = get_xmldoc('List Mirrors', request, 'listftpmirrors')
 
-    filter = setup_filter(pagenode, request.GET, {
+    filter = setup_filter(pagenode, request, {
         'keyword': lambda keyword: Q(name__contains=keyword) | Q(url__contains=keyword)
     })
 
@@ -283,7 +289,7 @@
 def list_foundationmembers(request):
     doc, pagenode = get_xmldoc('List Foundation Members', request, 'listfoundationmembers')
 
-    filter = setup_filter(pagenode, request.GET, {
+    filter = setup_filter(pagenode, request, {
         'keyword': lambda keyword: Q(lastname__icontains=keyword) | Q(firstname__icontains=keyword) | Q(email__icontains=keyword),
         'status': {
             'current': lambda keyword: Q(last_renewed_on__gte=datetime.date.today() - datetime.timedelta(days=700))  ,
@@ -335,7 +341,7 @@
 def list_modules(request):
     doc, pagenode = get_xmldoc('List Modules', request, 'listmodules')
 
-    filter = setup_filter(pagenode, request.GET, {
+    filter = setup_filter(pagenode, request, {
         'keyword': lambda keyword: Q(cn=keyword) | Q(maintainerUid=keyword)
     })
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]