michael-s-molina commented on code in PR #19981:
URL: https://github.com/apache/superset/pull/19981#discussion_r870272843
##########
superset/explore/utils.py:
##########
@@ -24,15 +24,24 @@
ChartNotFoundError,
)
from superset.charts.dao import ChartDAO
+from superset.commands.exceptions import DatasourceNotFoundValidationError
from superset.datasets.commands.exceptions import (
DatasetAccessDeniedError,
DatasetNotFoundError,
)
from superset.datasets.dao import DatasetDAO
+from superset.utils.core import DatasourceType
from superset.views.base import is_user_admin
from superset.views.utils import is_owner
+def check_datasource_access(datasource_id: int, datasource_type: str) ->
Optional[bool]:
+ if datasource_id:
+ if datasource_type == DatasourceType.TABLE:
+ return check_dataset_access(datasource_id)
+ raise DatasourceNotFoundValidationError
+
+
def check_dataset_access(dataset_id: int) -> Optional[bool]:
Review Comment:
The `check_dataset_access` is not being used anymore, right? If so, can we
remove it?
##########
superset/explore/form_data/commands/parameters.py:
##########
@@ -23,7 +23,8 @@
@dataclass
class CommandParameters:
actor: User
- dataset_id: int = 0
+ datasource_type: str = ""
+ datasource_id: int = 0
Review Comment:
I think it's a good idea to break it into multiple classes 👍🏼
##########
tests/integration_tests/explore/form_data/api_tests.py:
##########
@@ -67,65 +67,91 @@ def dataset_id() -> int:
return dataset.id
[email protected]
Review Comment:
Maybe have one fixture that returns the `datasource` with both `id` and
`type`?
--
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]