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 c082514
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions openedx_tagging/core/tagging/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ def can_change_tag(user: UserType, tag: Tag | None = None) -> bool:
)


@rules.predicate
def can_view_object_tag_taxonomy(user: UserType, taxonomy: Taxonomy) -> bool:
"""
Everybody can view object tags from any objects.
This rule could be defined in other apps for proper permission checking.
"""
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 +174,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 c082514

Please sign in to comment.