betodealmeida commented on a change in pull request #17223:
URL: https://github.com/apache/superset/pull/17223#discussion_r737700861
##########
File path: superset/reports/api.py
##########
@@ -386,6 +386,19 @@ def put(self, pk: int) -> Response:
return self.response_400(message=error.messages)
try:
new_model = UpdateReportScheduleCommand(g.user, pk, item).run()
+
+ if request.json.get("show_owners"):
+ owners = []
+ for o in new_model.owners:
+ owners.append(
+ {
+ "first_name": o.first_name,
+ "last_name": o.last_name,
+ "id": o.id,
+ }
+ )
+ item["owners"] = owners
Review comment:
List comprehensions are more idiomatic in Python:
```suggestion
item["owners"] = [
{
"first_name": owner.first_name,
"last_name": owner.last_name,
"id": owner.id,
}
for owner in new_model.owners
]
```
##########
File path: superset/reports/schemas.py
##########
@@ -283,3 +283,5 @@ class ReportSchedulePutSchema(Schema):
default=ReportDataFormat.VISUALIZATION,
validate=validate.OneOf(choices=tuple(key.value for key in
ReportDataFormat)),
)
+ # render entire owners object info
+ show_owners = fields.Boolean(required=False)
Review comment:
Is there a reason to not show owners? Any downside in always returning
it?
##########
File path: superset-frontend/src/views/CRUD/alert/AlertReportModal.tsx
##########
@@ -517,7 +517,7 @@ const AlertReportModal:
FunctionComponent<AlertReportModalProps> = ({
contentType === 'dashboard' ? currentAlert?.dashboard?.value : null,
database: currentAlert?.database?.value,
owners: (currentAlert?.owners || []).map(
- owner => (owner as MetaObject).value,
+ owner => (owner as MetaObject).value || owner.id,
Review comment:
Is `owner.value` the name of the owner? Why do we have to fallback to
`owner.id`?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]