superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maximebeauche...@apache.org
Subject [incubator-superset] branch master updated: Create CsvResponse to manage csv exports encoding (#3484)
Date Mon, 18 Sep 2017 16:51:15 GMT
This is an automated email from the ASF dual-hosted git repository.

maximebeauchemin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new a26e65f  Create CsvResponse to manage csv exports encoding (#3484)
a26e65f is described below

commit a26e65f418e6d83e389b285eb3cdeb7df84afbed
Author: JulieRossi <julierossi06@gmail.com>
AuthorDate: Mon Sep 18 18:51:13 2017 +0200

    Create CsvResponse to manage csv exports encoding (#3484)
---
 superset/views/base.py | 7 +++++++
 superset/views/core.py | 6 +++---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/superset/views/base.py b/superset/views/base.py
index 02aaf8d..73627d0 100644
--- a/superset/views/base.py
+++ b/superset/views/base.py
@@ -336,3 +336,10 @@ class DatasourceFilter(SupersetFilter):
         perms = self.get_view_menus('datasource_access')
         # TODO(bogdan): add `schema_access` support here
         return query.filter(self.model.perm.in_(perms))
+
+
+class CsvResponse(Response):
+    """
+    Override Response to take into account csv encoding from config.py
+    """
+    charset = conf.get('CSV_EXPORT').get('encoding', 'utf-8')
diff --git a/superset/views/core.py b/superset/views/core.py
index 72d2cf6..faa61ad 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -43,8 +43,8 @@ from superset.sql_parse import SupersetQuery
 
 from .base import (
     api, SupersetModelView, BaseSupersetView, DeleteMixin,
-    SupersetFilter, get_user_roles, json_error_response, get_error_msg
-)
+    SupersetFilter, get_user_roles, json_error_response, get_error_msg,
+    CsvResponse)
 
 config = app.config
 stats_logger = config.get('STATS_LOGGER')
@@ -959,7 +959,7 @@ class Superset(BaseSupersetView):
             return json_error_response(DATASOURCE_ACCESS_ERR, status=404)
 
         if request.args.get("csv") == "true":
-            return Response(
+            return CsvResponse(
                 viz_obj.get_csv(),
                 status=200,
                 headers=generate_download_headers("csv"),

-- 
To stop receiving notification emails like this one, please contact
['"commits@superset.apache.org" <commits@superset.apache.org>'].

Mime
View raw message