Skip to content

Commit

Permalink
Merge pull request #75 from PROCOLLAB-github/dev
Browse files Browse the repository at this point in the history
hopefully /accept/ now should add collaborators to projects
  • Loading branch information
VeryBigSad authored Nov 21, 2022
2 parents 44699ea + a8b0b49 commit f468723
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions invites/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from invites.filters import InviteFilter
from invites.models import Invite
from invites.serializers import InviteListSerializer, InviteDetailSerializer
from projects.models import Collaborator


class InviteList(generics.ListCreateAPIView):
Expand Down Expand Up @@ -43,11 +44,13 @@ class InviteAccept(generics.GenericAPIView):
permission_classes = [permissions.IsAuthenticatedOrReadOnly]

def post(self, request, *args, **kwargs):
invite = self.get_object()
invite = self.get_object() # type: Invite
if invite.user != request.user:
return Response(status=status.HTTP_403_FORBIDDEN)
# add user to project collaborators
invite.project.collaborators.add(invite.user)
Collaborator.objects.create(
user=invite.user, project=invite.project, role=invite.role
)
invite.is_accepted = True
invite.save()
return Response(status=status.HTTP_200_OK)
Expand Down

0 comments on commit f468723

Please sign in to comment.