def user(self, request, pk=None): request_user = self.request.user group = self.get_object() user_id = request.DATA.get('id') user = User.objects.get(pk=user_id) if user: new_user = UserRole(group=group, user=user) new_user.save() return Response(UserRoleSerializer(new_user).data, status=status.HTTP_201_CREATED) else: return Response("User not Found", status=status.HTTP_400_BAD_REQUEST)
def post_save(self, group, created): if created: create_default_categories(group=group) new_user = UserRole(group=group, user=self.request.user, accepted=True, is_admin=True) new_user.save()