Skip to content

Commit

Permalink
[FC-0049] feat: Update remove object-tag permission (#34728)
Browse files Browse the repository at this point in the history
* feat: Update remove object-tag permission

* chore: Bump openedx-learning version
  • Loading branch information
ChrisChV authored May 9, 2024
1 parent 0d13468 commit 7f6133c
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 5 deletions.
25 changes: 25 additions & 0 deletions openedx/core/djangoapps/content_tagging/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,30 @@ def can_view_object_tag_objectid(user: UserType, object_id: str) -> bool:
return bool(object_org) and (is_org_admin(user, object_org) or is_org_user(user, object_org))


@rules.predicate
def can_remove_object_tag_objectid(user: UserType, object_id: str) -> bool:
"""
Everyone that has permission to edit the object should be able remove tags from it.
"""
if not object_id:
raise ValueError("object_id must be provided")

if not user.is_authenticated:
return False

try:
context_key = get_context_key_from_key_string(object_id)
assert context_key.org
except (ValueError, AssertionError):
return False

if has_studio_write_access(user, context_key):
return True

object_org = rules_cache.get_orgs([context_key.org])
return bool(object_org) and is_org_admin(user, object_org)


@rules.predicate
def can_change_object_tag(
user: UserType, perm_obj: oel_tagging.ObjectTagPermissionItem | None = None
Expand Down Expand Up @@ -336,3 +360,4 @@ def can_change_taxonomy_tag(user: UserType, tag: oel_tagging.Tag | None = None)
rules.set_perm("oel_tagging.view_objecttag_objectid", can_view_object_tag_objectid)
rules.set_perm("oel_tagging.change_objecttag_taxonomy", can_view_object_tag_taxonomy)
rules.set_perm("oel_tagging.change_objecttag_objectid", can_change_object_tag_objectid)
rules.set_perm("oel_tagging.remove_objecttag_objectid", can_remove_object_tag_objectid)
2 changes: 1 addition & 1 deletion requirements/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ libsass==0.10.0
click==8.1.6

# pinning this version to avoid updates while the library is being developed
openedx-learning==0.9.2
openedx-learning==0.9.3

# Open AI version 1.0.0 dropped support for openai.ChatCompletion which is currently in use in enterprise.
openai<=0.28.1
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ openedx-filters==1.8.1
# -r requirements/edx/kernel.in
# lti-consumer-xblock
# ora2
openedx-learning==0.9.2
openedx-learning==0.9.3
# via
# -c requirements/edx/../constraints.txt
# -r requirements/edx/kernel.in
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,7 @@ openedx-filters==1.8.1
# -r requirements/edx/testing.txt
# lti-consumer-xblock
# ora2
openedx-learning==0.9.2
openedx-learning==0.9.3
# via
# -c requirements/edx/../constraints.txt
# -r requirements/edx/doc.txt
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ openedx-filters==1.8.1
# -r requirements/edx/base.txt
# lti-consumer-xblock
# ora2
openedx-learning==0.9.2
openedx-learning==0.9.3
# via
# -c requirements/edx/../constraints.txt
# -r requirements/edx/base.txt
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/testing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ openedx-filters==1.8.1
# -r requirements/edx/base.txt
# lti-consumer-xblock
# ora2
openedx-learning==0.9.2
openedx-learning==0.9.3
# via
# -c requirements/edx/../constraints.txt
# -r requirements/edx/base.txt
Expand Down

0 comments on commit 7f6133c

Please sign in to comment.