diff --git a/superset/views/core.py b/superset/views/core.py index 52550695e53..ca6697cfc3f 100755 --- a/superset/views/core.py +++ b/superset/views/core.py @@ -1290,7 +1290,9 @@ class Superset(BaseSupersetView): title = _("Explore - %(table)s", table=table_name) return self.render_template( "superset/basic.html", - bootstrap_data=json.dumps(bootstrap_data), + bootstrap_data=json.dumps( + bootstrap_data, default=utils.pessimistic_json_iso_dttm_ser + ), entry="explore", title=title, standalone_mode=standalone, @@ -2200,14 +2202,18 @@ class Superset(BaseSupersetView): } if request.args.get("json") == "true": - return json_success(json.dumps(bootstrap_data)) + return json_success( + json.dumps(bootstrap_data, default=utils.pessimistic_json_iso_dttm_ser) + ) return self.render_template( "superset/dashboard.html", entry="dashboard", standalone_mode=standalone_mode, title=dash.dashboard_title, - bootstrap_data=json.dumps(bootstrap_data), + bootstrap_data=json.dumps( + bootstrap_data, default=utils.pessimistic_json_iso_dttm_ser + ), ) @api @@ -3009,7 +3015,9 @@ class Superset(BaseSupersetView): "superset/basic.html", title=_("%(user)s's profile", user=username), entry="profile", - bootstrap_data=json.dumps(payload, default=utils.json_iso_dttm_ser), + bootstrap_data=json.dumps( + payload, default=utils.pessimistic_json_iso_dttm_ser + ), ) @has_access diff --git a/tests/core_tests.py b/tests/core_tests.py index 1e640493d3a..50605a90369 100644 --- a/tests/core_tests.py +++ b/tests/core_tests.py @@ -963,11 +963,16 @@ class CoreTests(SupersetTestCase): ) html = cgi.escape(encoded).replace("'", "'").replace('"', """) - data = self.get_resp("/superset/sqllab") - self.assertTrue(html in data) - - data = self.get_resp("/superset/welcome") - self.assertTrue(html in data) + urls = [ + "/superset/sqllab", + "/superset/welcome", + "/superset/dashboard/1/", + "/superset/profile/admin/", + "/superset/explore/table/1", + ] + for url in urls: + data = self.get_resp(url) + self.assertTrue(html in data) if __name__ == "__main__":