def _serialize_member(self, member, request, allowed_roles=None):
        context = serialize(member, serializer=OrganizationMemberWithTeamsSerializer())

        if request.access.has_scope("member:admin"):
            context["invite_link"] = member.get_invite_link()
            context["user"] = serialize(member.user, request.user, DetailedUserSerializer())

        context["isOnlyOwner"] = self.is_only_owner(member)
        context["roles"] = serialize(
            roles.get_all(), serializer=RoleSerializer(), allowed_roles=allowed_roles
        )

        return context
Ejemplo n.º 2
0
    def get(self, request):
        if not request.user.is_authenticated():
            return Response(status=status.HTTP_400_BAD_REQUEST)

        user = extract_lazy_object(request._request.user)
        return Response(serialize(user, user, DetailedUserSerializer()))