Properly handle exports when there are multiple lists
authorSverre Rabbelier <srabbelier@gmail.com>
Mon, 06 Apr 2009 23:46:46 +0000
changeset 2108 286aa6528e84
parent 2107 855daf131060
child 2109 3b349cd95b07
Properly handle exports when there are multiple lists If there are multiple lists whose index does not match their position in the contents, things weren't handled properly. Patch by: Sverre Rabbelier
app/soc/logic/lists.py
app/soc/views/helper/lists.py
app/soc/views/models/base.py
--- a/app/soc/logic/lists.py	Mon Apr 06 22:55:49 2009 +0000
+++ b/app/soc/logic/lists.py	Mon Apr 06 23:46:46 2009 +0000
@@ -39,6 +39,7 @@
       'next',
       'first',
       'last',
+      'idx',
       ]
 
   def __init__(self, contents):
--- a/app/soc/views/helper/lists.py	Mon Apr 06 22:55:49 2009 +0000
+++ b/app/soc/views/helper/lists.py	Mon Apr 06 23:46:46 2009 +0000
@@ -195,6 +195,7 @@
     newest = generateLinkFromGetArgs(request, newest_params)
 
   content = {
+      'idx': idx,
       'data': data,
       'export': export_link,
       'first': offset+1,
--- a/app/soc/views/models/base.py	Mon Apr 06 22:55:49 2009 +0000
+++ b/app/soc/views/models/base.py	Mon Apr 06 23:46:46 2009 +0000
@@ -546,8 +546,9 @@
     except ValueError:
       export = None
 
-    if export is not None and export < len(contents):
-      content = contents[export]
+    content = [i for i in contents if i['idx'] == export]
+    if len(content) == 1:
+      content = content[0]
       key_order = content.get('key_order')
 
       if key_order: