john-bodley 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_r391310885
##########
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:
@villebro per the
[`dict.get`](https://docs.python.org/3/library/stdtypes.html#dict.get) docs,
the default is only returned if the key does not exist. I think the desired
logic should be,
```python
if "owners" in data and data["owners"] is None:
data["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]