1212from openedx_authz .constants .permissions import COURSES_MANAGE_TAGS , COURSES_VIEW_COURSE
1313from openedx_tagging import rules as oel_tagging_rules
1414from openedx_tagging .api import TagDoesNotExist
15- from openedx_tagging .rest_api .v1 .serializers import ObjectTagUpdateBodySerializer
1615from openedx_tagging .rest_api .v1 .views import ObjectTagView , TaxonomyView
1716from rest_framework import status
1817from rest_framework .decorators import action
19- from rest_framework .exceptions import MethodNotAllowed , PermissionDenied , ValidationError
18+ from rest_framework .exceptions import PermissionDenied , ValidationError
2019from rest_framework .permissions import IsAuthenticated
2120from rest_framework .response import Response
2221from rest_framework .views import APIView
@@ -227,33 +226,18 @@ def ensure_user_has_can_tag_object_permissions(self, user, tags_data, object_id)
227226 # Fall back to parent implementation
228227 super ().ensure_user_has_can_tag_object_permissions (user , tags_data , object_id )
229228
230- def update (self , request , * args , ** kwargs ) -> Response :
229+ def _apply_updated_tags (self , data : dict , object_id : str ) :
231230 """
232- Update the tags applied to the given object_id.
233-
234- This overrides ObjectTagView.update so that the tags are applied using this
235- platform's ``tag_object`` API, which only allows tagging with taxonomies that
236- are enabled for the object's organization, and which fires the
237- CONTENT_OBJECT_ASSOCIATIONS_CHANGED / CONTENT_OBJECT_TAGS_CHANGED events.
231+ This overrides the helper method used by ObjectTagView.update() so that the tags are applied using this
232+ platform's ``tag_object`` API, which only allows tagging with taxonomies that are enabled for the object's
233+ organization, and which fires the CONTENT_OBJECT_ASSOCIATIONS_CHANGED / CONTENT_OBJECT_TAGS_CHANGED events.
238234 """
239- partial = kwargs .pop ('partial' , False )
240- if partial :
241- raise MethodNotAllowed ("PATCH" , detail = "PATCH not allowed" )
242-
243- object_id = kwargs .pop ('object_id' )
244- body = ObjectTagUpdateBodySerializer (data = request .data )
245- body .is_valid (raise_exception = True )
246-
247- data = body .validated_data .get ("tagsData" , [])
248-
249- # Check permissions
250- self .ensure_user_has_can_tag_object_permissions (request .user , data , object_id )
251-
252235 # Tag object_id per taxonomy
253236 for tag_data in data :
254237 taxonomy = tag_data .get ("taxonomy" )
255238 tags = tag_data .get ("tags" , [])
256239 try :
240+ # Call our `tag_object`, not oel_tagging's `tag_object`
257241 tag_object (object_id , taxonomy , tags )
258242 except InvalidOrgException as e :
259243 raise ValidationError (e .messages ) from e
@@ -262,8 +246,6 @@ def update(self, request, *args, **kwargs) -> Response:
262246 except ValueError as e :
263247 raise ValidationError from e
264248
265- return self .retrieve (request , object_id )
266-
267249
268250class ObjectTagExportView (APIView ):
269251 """"
0 commit comments