jedcunningham commented on code in PR #23510:
URL: https://github.com/apache/airflow/pull/23510#discussion_r874825186
##########
airflow/security/permissions.py:
##########
@@ -66,14 +66,16 @@
DAG_ACTIONS = {ACTION_CAN_READ, ACTION_CAN_EDIT, ACTION_CAN_DELETE}
-def resource_name_for_dag(dag_id):
+def resource_name_for_dag(dag_id, is_subdag=False):
"""Returns the resource name for a DAG id."""
if dag_id == RESOURCE_DAG:
return dag_id
if dag_id.startswith(RESOURCE_DAG_PREFIX):
return dag_id
- # To account for SubDags
- root_dag_id = dag_id.split(".")[0]
- return f"{RESOURCE_DAG_PREFIX}{root_dag_id}"
+ if '.' in dag_id and is_subdag:
Review Comment:
```suggestion
if is_subdag:
```
If it's a subdag, isn't it always going to have a '.' in there?
##########
airflow/www/security.py:
##########
@@ -200,6 +200,16 @@ def __init__(self, appbuilder):
view.datamodel = CustomSQLAInterface(view.datamodel.obj)
self.perms = None
+ def _is_subdag(self, dag_id):
+ if '.' in dag_id:
+ dm = (
+ self.get_session.query(DagModel.dag_id, DagModel.is_subdag)
Review Comment:
```suggestion
self.get_session.query(DagModel.is_subdag)
```
Only need this field, yeah?
--
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]