Invitations: error when trying to invite oneself.
This commit is contained in:
parent
8593ab1357
commit
2327466113
@ -568,6 +568,10 @@ class InvitationOutgoingViewSet(InvitationBaseViewSet):
|
|||||||
except Collection.DoesNotExist:
|
except Collection.DoesNotExist:
|
||||||
raise Http404('Collection does not exist')
|
raise Http404('Collection does not exist')
|
||||||
|
|
||||||
|
if request.user == serializer.validated_data.get('user'):
|
||||||
|
content = {'code': 'self_invite', 'detail': 'Inviting yourself is invalid'}
|
||||||
|
return Response(content, status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
if not permissions.is_collection_admin(collection, request.user):
|
if not permissions.is_collection_admin(collection, request.user):
|
||||||
raise PermissionDenied('User is not an admin of this collection')
|
raise PermissionDenied('User is not an admin of this collection')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user