"""
    Prevents ability to pass primary keys of objects relating to DAGs you shouldn't be able to edit.
    This only holds for the add, update and delete operations.
    You will still need to use the `action_has_dag_edit_access()` for actions.
    """
    @staticmethod
    def validate_dag_edit_access(item: DagRun | TaskInstance):
        """Validates whether the user has 'can_edit' access for this specific DAG."""
        if not get_airflow_app().appbuilder.sm.can_edit_dag(item.dag_id):
            raise AirflowException(f"Access denied for dag_id {item.dag_id}")
    def pre_add(self, item: DagRun | TaskInstance):
        self.validate_dag_edit_access(item)
    def pre_update(self, item: DagRun | TaskInstance):
        self.validate_dag_edit_access(item)
    def pre_delete(self, item: DagRun | TaskInstance):
        self.validate_dag_edit_access(item)
    def post_add_redirect(self):  
        return redirect(self.get_default_url())
    def post_edit_redirect(self):  
        return redirect(self.get_default_url())
    def post_delete_redirect(self):