summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@proxience.com>2015-09-29 11:02:58 +0200
committerÉtienne Loks <etienne.loks@proxience.com>2015-09-29 11:03:18 +0200
commitad8c05a61b47839d7d386ef5adc76231b581b395 (patch)
tree39e08eeaa6d685680445e6d3ee70bc4563e0684d
parentbc13bd14179f6bbc5838a41a2053443268cd1b67 (diff)
downloadIshtar-ad8c05a61b47839d7d386ef5adc76231b581b395.tar.bz2
Ishtar-ad8c05a61b47839d7d386ef5adc76231b581b395.zip
Add full export to dynamic table
-rw-r--r--ishtar_common/templates/ishtar/blocks/window_tables/dynamic_documents.html10
-rw-r--r--ishtar_common/templatetags/window_tables.py22
2 files changed, 25 insertions, 7 deletions
diff --git a/ishtar_common/templates/ishtar/blocks/window_tables/dynamic_documents.html b/ishtar_common/templates/ishtar/blocks/window_tables/dynamic_documents.html
index bd83983f4..dce0a2c2e 100644
--- a/ishtar_common/templates/ishtar/blocks/window_tables/dynamic_documents.html
+++ b/ishtar_common/templates/ishtar/blocks/window_tables/dynamic_documents.html
@@ -4,6 +4,16 @@
<table id='grid_{{name}}' class='jqgrid'></table>
<div id='pager_{{name}}'></div>
+<div id='foot_{{name}}' class='gridfooter'>
+{% if source_full %}
+{% trans "Export as CSV" %} ({{encoding}})
+<a href='{{simple_source}}csv{{ source_attrs }}' target='_blank'>{% trans "simple" %}</a> -
+<a href='{{source_full}}csv{{ source_attrs }}' target='_blank'>{% trans "full" %}</a>
+{% else %}
+<a href="{{simple_source}}csv{{ source_attrs }}" target="_blank">{% trans "Export as CSV" %} ({{encoding}})</a>
+{% endif %}
+</div>
+
<script type="text/javascript" language='javascript'>
setTimeout(
diff --git a/ishtar_common/templatetags/window_tables.py b/ishtar_common/templatetags/window_tables.py
index a135ad5c0..36d9dd236 100644
--- a/ishtar_common/templatetags/window_tables.py
+++ b/ishtar_common/templatetags/window_tables.py
@@ -1,6 +1,7 @@
import time
from django import template
+from django.conf import settings
from django.template.defaultfilters import slugify
from django.utils.translation import ugettext_lazy as _
@@ -18,37 +19,44 @@ ASSOCIATED_MODELS = {}
try:
from archaeological_operations.models import OperationSource
ASSOCIATED_MODELS['operation_docs'] = (OperationSource,
- 'get-operationsource')
+ 'get-operationsource', '')
except:
pass
try:
from archaeological_context_records.models import ContextRecord, \
ContextRecordSource
- ASSOCIATED_MODELS['context_records'] = (ContextRecord, 'get-contextrecord')
+ ASSOCIATED_MODELS['context_records'] = (ContextRecord, 'get-contextrecord',
+ 'get-contextrecord-full')
ASSOCIATED_MODELS['context_records_docs'] = (ContextRecordSource,
- 'get-contextrecordsource')
+ 'get-contextrecordsource', '')
except:
pass
try:
from archaeological_finds.models import Find
- ASSOCIATED_MODELS['finds'] = (Find, 'get-find')
+ ASSOCIATED_MODELS['finds'] = (Find, 'get-find', 'get-find-full')
except:
pass
@register.inclusion_tag('ishtar/blocks/window_tables/dynamic_documents.html')
def dynamic_table_document(caption, associated_model, key, value):
- model, url = ASSOCIATED_MODELS[associated_model]
+ model, url, url_full = ASSOCIATED_MODELS[associated_model]
grid = JQueryJqGrid(None, None, model)
-
+ source = unicode(reverse_lazy(url))
+ source_full = unicode(reverse_lazy(url_full)) if url_full else ''
+ source_attrs = '?{}={}'.format(key, value)
col_names, extra_cols = grid.get_cols()
return {'caption': caption,
'name': slugify(caption) + '{}'.format(int(time.time())),
- 'source': unicode(reverse_lazy(url)) + '?{}={}'.format(key, value),
+ 'source': source + source_attrs,
+ 'source_full': source_full,
+ 'simple_source': source,
+ 'source_attrs': source_attrs,
'col_names': col_names,
'extra_cols': extra_cols,
'no_result': unicode(_("No results")),
'loading': unicode(_("Loading...")),
+ 'encoding': settings.ENCODING or 'utf-8',
}