You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by gr...@apache.org on 2019/07/19 22:36:34 UTC
[incubator-superset] branch master updated: [test] Fix test data
remove slice_name (#7898)
This is an automated email from the ASF dual-hosted git repository.
graceguo 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 f570b45 [test] Fix test data remove slice_name (#7898)
f570b45 is described below
commit f570b459f2828cff25c81f9bfe4cd77a53269d91
Author: Grace Guo <gr...@airbnb.com>
AuthorDate: Fri Jul 19 15:36:19 2019 -0700
[test] Fix test data remove slice_name (#7898)
* [text] Fix test data remove slice_name
* fix review comment
---
superset/views/core.py | 29 ++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/superset/views/core.py b/superset/views/core.py
index b0dfda9..a11b316 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -1967,14 +1967,13 @@ class Superset(BaseSupersetView):
slice_ids = []
slice_id_to_name = {}
for value in positions.values():
- if (
- isinstance(value, dict)
- and value.get("meta")
- and value.get("meta").get("chartId")
- ):
- slice_id = value.get("meta").get("chartId")
- slice_ids.append(slice_id)
- slice_id_to_name[slice_id] = value.get("meta").get("sliceName")
+ if isinstance(value, dict):
+ try:
+ slice_id = value["meta"]["chartId"]
+ slice_ids.append(slice_id)
+ slice_id_to_name[slice_id] = value["meta"]["sliceName"]
+ except KeyError:
+ pass
session = db.session()
Slice = models.Slice # noqa
@@ -1983,12 +1982,16 @@ class Superset(BaseSupersetView):
dashboard.slices = current_slices
# update slice names. this assumes user has permissions to update the slice
+ # we allow user set slice name be empty string
for slc in dashboard.slices:
- new_name = slice_id_to_name[slc.id]
- if slc.slice_name != new_name:
- slc.slice_name = new_name
- session.merge(slc)
- session.flush()
+ try:
+ new_name = slice_id_to_name[slc.id]
+ if slc.slice_name != new_name:
+ slc.slice_name = new_name
+ session.merge(slc)
+ session.flush()
+ except KeyError:
+ pass
# remove leading and trailing white spaces in the dumped json
dashboard.position_json = json.dumps(