john-bodley commented on code in PR #20499:
URL: https://github.com/apache/superset/pull/20499#discussion_r916077916


##########
superset/security/manager.py:
##########
@@ -1520,3 +1517,70 @@ def has_guest_access(self, dashboard: "Dashboard") -> 
bool:
             if str(resource["id"]) == str(dashboard.embedded[0].uuid):
                 return True
         return False
+
+    def raise_for_ownership(self, resource: Model) -> None:
+        """
+        Raise an exception if the user does not own the resource.
+
+        Note admins are deemed owners of all resources.
+
+        :param resource: The dashboard, dataste, chart, etc. resource
+        :raises SupersetSecurityException: If the current user is not an owner
+        """
+
+        # pylint: disable=import-outside-toplevel
+        from superset import db
+
+        if self.is_admin():
+            return
+
+        orig_resource = (
+            
db.session.query(resource.__class__).filter_by(id=resource.id).first()

Review Comment:
   @dpgaspar I agree with the `one_or_none`. This was a copy-and-paste from 
`check_ownership` but I'll make the update.



-- 
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]

Reply via email to