villebro commented on a change in pull request #9279: [dashboard][api] Fix, PUT
publish/draft to not clean slug and owners
URL:
https://github.com/apache/incubator-superset/pull/9279#discussion_r391287338
##########
File path: superset/views/dashboard/api.py
##########
@@ -88,12 +88,12 @@ class BaseDashboardSchema(BaseOwnedSchema):
@pre_load
def pre_load(self, data): # pylint: disable=no-self-use
super().pre_load(data)
- data["slug"] = data.get("slug")
- data["owners"] = data.get("owners", [])
- if data["slug"]:
+ if data.get("slug"):
data["slug"] = data["slug"].strip()
data["slug"] = data["slug"].replace(" ", "-")
data["slug"] = re.sub(r"[^\w\-]+", "", data["slug"])
+ if "owners" in data:
+ data["owners"] = data.get("owners", [])
Review comment:
I think this is to make sure that `owners` is always a list if the key is
present. With the help of these two rows, if `data == {"owners": None}`, `data`
becomes `{"owners": []}`, but doesn't get set if `data` doesn't contain the key
`owners`.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]