Override create method to add new organisation to authenticated user
(self, request, **kwargs)
| 116 | return super(OrganisationViewSet, self).get_throttles() |
| 117 | |
| 118 | def create(self, request, **kwargs): # type: ignore[no-untyped-def] |
| 119 | """ |
| 120 | Override create method to add new organisation to authenticated user |
| 121 | """ |
| 122 | |
| 123 | user = request.user |
| 124 | serializer = OrganisationSerializerFull(data=request.data) |
| 125 | if serializer.is_valid(): |
| 126 | org = serializer.save() |
| 127 | user.add_organisation(org, OrganisationRole.ADMIN) |
| 128 | |
| 129 | return Response(serializer.data, status.HTTP_201_CREATED) |
| 130 | else: |
| 131 | return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) |
| 132 | |
| 133 | @action( |
| 134 | detail=False, |
no test coverage detected