diff --git a/openedx/core/djangoapps/content_tagging/rules.py b/openedx/core/djangoapps/content_tagging/rules.py index 265194860159..72b744f5bf8e 100644 --- a/openedx/core/djangoapps/content_tagging/rules.py +++ b/openedx/core/djangoapps/content_tagging/rules.py @@ -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 @@ -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) diff --git a/requirements/constraints.txt b/requirements/constraints.txt index dc52f4317ba2..76f2b6057a77 100644 --- a/requirements/constraints.txt +++ b/requirements/constraints.txt @@ -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 diff --git a/requirements/edx/base.txt b/requirements/edx/base.txt index 11b5bab8ab57..517f4a722e01 100644 --- a/requirements/edx/base.txt +++ b/requirements/edx/base.txt @@ -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 diff --git a/requirements/edx/development.txt b/requirements/edx/development.txt index 857555cd84a3..22da086ac200 100644 --- a/requirements/edx/development.txt +++ b/requirements/edx/development.txt @@ -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 diff --git a/requirements/edx/doc.txt b/requirements/edx/doc.txt index abebb10842eb..8d53f3852cb7 100644 --- a/requirements/edx/doc.txt +++ b/requirements/edx/doc.txt @@ -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 diff --git a/requirements/edx/testing.txt b/requirements/edx/testing.txt index 05fd3b815a1c..d640dc7fc5cd 100644 --- a/requirements/edx/testing.txt +++ b/requirements/edx/testing.txt @@ -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