(self, request, organisation_pk, pk)
| 236 | ) |
| 237 | @action(detail=True, methods=["POST"], url_path="add-users") |
| 238 | def add_users(self, request, organisation_pk, pk): # type: ignore[no-untyped-def] |
| 239 | group = self.get_object() |
| 240 | user_ids = request.data["user_ids"] |
| 241 | |
| 242 | if ( |
| 243 | isinstance(request.user, FFAdminUser) |
| 244 | and request.user.id in user_ids |
| 245 | and not request.user.is_organisation_admin( |
| 246 | Organisation.objects.get(pk=organisation_pk) |
| 247 | ) |
| 248 | ): |
| 249 | raise PermissionDenied("Non-admin users cannot add themselves to a group.") |
| 250 | |
| 251 | try: |
| 252 | group.add_users_by_id(user_ids) |
| 253 | except FFAdminUser.DoesNotExist as e: |
| 254 | return Response({"detail": str(e)}, status=status.HTTP_400_BAD_REQUEST) |
| 255 | |
| 256 | return Response(UserPermissionGroupSerializerDetail(instance=group).data) |
| 257 | |
| 258 | @extend_schema( |
| 259 | request=UserIdsSerializer, |
nothing calls this directly
no test coverage detected