From d85ee7f8499f016815fde0e650006f17af224683 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B4mulo=20Penido?= Date: Thu, 12 Oct 2023 13:50:33 -0300 Subject: [PATCH] refactor: add typings --- .../core/tagging/rest_api/v1/views.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/openedx_tagging/core/tagging/rest_api/v1/views.py b/openedx_tagging/core/tagging/rest_api/v1/views.py index baf91a67..fc953212 100644 --- a/openedx_tagging/core/tagging/rest_api/v1/views.py +++ b/openedx_tagging/core/tagging/rest_api/v1/views.py @@ -253,14 +253,17 @@ def get_queryset(self) -> models.QuerySet: object_id=object_id, ) - if not self.request.user.has_perm(perm, perm_obj): + if not self.request.user.has_perm( + perm, + perm_obj, # type: ignore[arg-type] + ): raise PermissionDenied( "You do not have permission to view object tags for this taxonomy or object_id." ) return get_object_tags(object_id, taxonomy_id) - def retrieve(self, request, *args, **kwargs): + def retrieve(self, request, *args, **kwargs) -> Response: """ Retrieve ObjectTags that belong to a given object_id @@ -275,7 +278,7 @@ def retrieve(self, request, *args, **kwargs): serializer = ObjectTagSerializer(object_tags, many=True) return Response(serializer.data) - def update(self, request, *args, **kwargs): + def update(self, request, *args, **kwargs) -> Response: """ Update ObjectTags that belong to a given object_id @@ -311,7 +314,7 @@ def update(self, request, *args, **kwargs): taxonomy = query_params.validated_data.get("taxonomy", None) taxonomy = taxonomy.cast() - perm = f"{taxonomy._meta.app_label}.change_objecttag" + perm = "oel_tagging.change_objecttag" object_id = kwargs.pop('object_id') perm_obj = ObjectTagPermissionItem( @@ -319,7 +322,10 @@ def update(self, request, *args, **kwargs): object_id=object_id, ) - if not request.user.has_perm(perm, perm_obj): + if not request.user.has_perm( + perm, + perm_obj, # type: ignore[arg-type] + ): raise PermissionDenied( "You do not have permission to change object tags for this taxonomy or object_id." )