Skip to content

Commit

Permalink
Handle no access to parent object gracefully (#51)
Browse files Browse the repository at this point in the history
* Handle no access to parent gracefully

* Changelog updated
  • Loading branch information
ramonski committed Oct 14, 2022
1 parent 4980fdb commit 2caad57
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Changelog
2.4.0 (unreleased)
------------------

- no changes yet
- #51 Handle no access to parent object gracefully


2.3.0 (2022-10-03)
Expand Down
9 changes: 8 additions & 1 deletion src/senaite/jsonapi/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,14 @@ def get_parent_info(brain_or_object, endpoint=None):
return {}

# get the parent object
parent = get_parent(brain_or_object)
try:
parent = get_parent(brain_or_object)
except Unauthorized:
return {
"parent_id": "",
"parent_uid": "",
"parent_url": "",
}
portal_type = get_portal_type(parent)
resource = portal_type_to_resource(portal_type)

Expand Down

0 comments on commit 2caad57

Please sign in to comment.