Add an export link to all list views
authorSverre Rabbelier <srabbelier@gmail.com>
Thu, 12 Mar 2009 13:39:57 +0000
changeset 1807 1f8cde169f32
parent 1806 d321d5123928
child 1808 f6ec0f486247
Add an export link to all list views Patch by: Sverre Rabbelier
app/soc/logic/lists.py
app/soc/templates/soc/list/pagination.html
app/soc/views/helper/lists.py
--- a/app/soc/logic/lists.py	Thu Mar 12 13:39:03 2009 +0000
+++ b/app/soc/logic/lists.py	Thu Mar 12 13:39:57 2009 +0000
@@ -30,6 +30,7 @@
       'pagination',
       'pagination_form',
       'description',
+      'export',
       'heading',
       'row',
       'limit',
--- a/app/soc/templates/soc/list/pagination.html	Thu Mar 12 13:39:03 2009 +0000
+++ b/app/soc/templates/soc/list/pagination.html	Thu Mar 12 13:39:57 2009 +0000
@@ -1,5 +1,11 @@
 <div class="pagination">
 
+{% with list.export as export_link %}
+{% if export_link %}
+<a href="{{ export_link }}" class="button" target="_blank">csv export</a>
+{% endif %}
+{% endwith %}
+
   {{ list.pagination_form.as_table }}
  
   {% if list.newest %}
--- a/app/soc/views/helper/lists.py	Thu Mar 12 13:39:03 2009 +0000
+++ b/app/soc/views/helper/lists.py	Thu Mar 12 13:39:57 2009 +0000
@@ -163,6 +163,10 @@
     if key.startswith('offset_') or key.startswith('limit_'):
       offset_and_limits[key] = value
 
+  offset_and_limits['export'] = idx
+  export_link = generateLinkFromGetArgs(request, offset_and_limits)
+  del offset_and_limits['export']
+
   if more:
     offset_and_limits[offset_key] = offset+limit
     offset_and_limits[limit_key] = limit
@@ -181,6 +185,7 @@
 
   content = {
       'data': data,
+      'export': export_link,
       'first': offset+1,
       'last': len(data) > 1 and offset+len(data) or None,
       'logic': logic,