Skip to content

Commit

Permalink
fix: add can_view_object_tag_taxonomy
Browse files Browse the repository at this point in the history
  • Loading branch information
rpenido committed Oct 16, 2023
1 parent 13feb1c commit 6b91980
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions openedx_tagging/core/tagging/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ def can_change_tag(user: UserType, tag: Tag | None = None) -> bool:
)


@rules.predicate
def can_view_object_tag_taxonomy(user: UserType, taxonomy: Taxonomy) -> bool:
"""
Only enabled taxonomy and users with permission to view this taxonomy can view object tags
from that taxonomy.
"""
return taxonomy.cast().enabled and can_view_taxonomy(user, taxonomy)


@rules.predicate
def can_view_object_tag_objectid(_user: UserType, _object_id: str) -> bool:
"""
Expand Down Expand Up @@ -164,6 +173,6 @@ def can_change_object_tag(

# Users can tag objects using tags from any taxonomy that they have permission to view
rules.add_perm("oel_tagging.view_objecttag_objectid", can_view_object_tag_objectid)
rules.add_perm("oel_tagging.view_objecttag_taxonomy", can_view_taxonomy)
rules.add_perm("oel_tagging.change_objecttag_taxonomy", can_view_taxonomy)
rules.add_perm("oel_tagging.view_objecttag_taxonomy", can_view_object_tag_taxonomy)
rules.add_perm("oel_tagging.change_objecttag_taxonomy", can_view_object_tag_taxonomy)
rules.add_perm("oel_tagging.change_objecttag_objectid", can_change_object_tag_objectid)

0 comments on commit 6b91980

Please sign in to comment.