Skip to content

Commit

Permalink
fix: restore lock APIs response code
Browse files Browse the repository at this point in the history
  • Loading branch information
francesco-filicetti committed Mar 15, 2024
1 parent 0b623bb commit 972f186
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/cms/api/views/locks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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({})


Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 972f186

Please sign in to comment.