Improved UI for CSV/JSON export, closes #266

This commit is contained in:
Simon Willison 2018-06-17 23:03:22 -07:00
commit 83f4ef7ec7
No known key found for this signature in database
GPG key ID: 17E2DEA2588B7F52
7 changed files with 78 additions and 14 deletions

View file

@ -382,6 +382,12 @@ class BaseView(RenderMixin):
url_labels_extra = {}
if data.get("expandable_columns"):
url_labels_extra = {"_labels": "on"}
url_csv_args = {
"_size": "max",
**url_labels_extra
}
url_csv = path_with_format(request, "csv", url_csv_args)
url_csv_path = url_csv.split('?')[0]
context = {
**data,
**extras,
@ -389,15 +395,9 @@ class BaseView(RenderMixin):
"url_json": path_with_format(request, "json", {
**url_labels_extra,
}),
"url_csv": path_with_format(request, "csv", {
"_size": "max",
**url_labels_extra
}),
"url_csv_dl": path_with_format(request, "csv", {
"_dl": "1",
"_size": "max",
**url_labels_extra
}),
"url_csv": url_csv,
"url_csv_path": url_csv_path,
"url_csv_args": url_csv_args,
"extra_css_urls": self.ds.extra_css_urls(),
"extra_js_urls": self.ds.extra_js_urls(),
"datasette_version": __version__,

View file

@ -10,6 +10,7 @@ from datasette.utils import (
CustomRow,
Filters,
InterruptedError,
append_querystring,
compound_keys_after_sql,
escape_sqlite,
filters_should_redirect,
@ -748,6 +749,7 @@ class TableView(RowTableShared):
"is_sortable": any(c["sortable"] for c in display_columns),
"path_with_replaced_args": path_with_replaced_args,
"path_with_removed_args": path_with_removed_args,
"append_querystring": append_querystring,
"request": request,
"sort": sort,
"sort_desc": sort_desc,