sha174n commented on code in PR #39303:
URL: https://github.com/apache/superset/pull/39303#discussion_r3294549458
##########
superset/commands/report/base.py:
##########
@@ -50,6 +53,34 @@ def run(self) -> Any:
def validate(self) -> None:
pass
+ def _check_chart_access(
+ self, chart_id: int, exceptions: list[ValidationError]
+ ) -> None:
+ """Validate chart exists and the current user can access it."""
+ chart = ChartDAO.find_by_id(chart_id)
+ if not chart:
+ exceptions.append(ChartNotFoundValidationError())
+ else:
+ try:
+ security_manager.raise_for_access(viz=chart)
+ except SupersetSecurityException as ex:
+ raise ReportScheduleForbiddenError() from ex
+ self._properties["chart"] = chart
+
+ def _check_dashboard_access(
+ self, dashboard_id: int, exceptions: list[ValidationError]
+ ) -> None:
+ """Validate dashboard exists and the current user can access it."""
+ dashboard = DashboardDAO.find_by_id(dashboard_id)
+ if not dashboard:
+ exceptions.append(DashboardNotFoundValidationError())
+ else:
+ try:
+ security_manager.raise_for_access(dashboard=dashboard)
+ except SupersetSecurityException as ex:
+ raise ReportScheduleForbiddenError() from ex
+ self._properties["dashboard"] = dashboard
Review Comment:
Consolidated into a single `_check_object_access` helper parameterised by
`kind`, `dao`, and `not_found_exc` in c018a8f50d.
--
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]