From 972f186b0586b789fd6986fed594a534799b5c8f Mon Sep 17 00:00:00 2001 From: Francesco Filicetti Date: Fri, 15 Mar 2024 19:55:54 +0100 Subject: [PATCH] fix: restore lock APIs response code --- src/cms/api/views/locks.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/cms/api/views/locks.py b/src/cms/api/views/locks.py index 3de7060..55b4450 100644 --- a/src/cms/api/views/locks.py +++ b/src/cms/api/views/locks.py @@ -139,9 +139,8 @@ def get(self, request, *args, **kwargs): user_lock = get_lock_from_cache(content_type_id, object_id) if user_lock and not user_lock == request.user.pk: # pragma: no cover owner_user = get_user_model().objects.filter(pk=user_lock).first() - # return Response({'lock': lock, - # 'message': LOCK_MESSAGE.format(user=owner_user)}) - raise PermissionDenied(LOCK_MESSAGE.format(user=owner_user), 403) + return Response({'message': LOCK_MESSAGE.format(user=owner_user)}) + # raise PermissionDenied(LOCK_MESSAGE.format(user=owner_user), 403) return Response({}) @@ -191,9 +190,8 @@ def post(self, request, *args, **kwargs): user_lock = get_lock_from_cache(content_type_id, object_id) if user_lock and not user_lock == request.user.pk: # pragma: no cover owner_user = get_user_model().objects.filter(pk=user_lock).first() - # return Response({'lock': lock, - # 'message': LOCK_MESSAGE.format(user=owner_user)}) - raise PermissionDenied(LOCK_MESSAGE.format(user=owner_user), 403) + return Response({'message': LOCK_MESSAGE.format(user=owner_user)}) + # raise PermissionDenied(LOCK_MESSAGE.format(user=owner_user), 403) if obj.is_lockable_by(request.user): set_lock_to_cache(user_id=request.user.pk, content_type_id=content_type_id,