コード例 #1
0
    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['roles'] = serialize(roles.get_all(),
                                     serializer=RoleSerializer(),
                                     allowed_roles=allowed_roles)

        return context
コード例 #2
0
    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
コード例 #3
0
    def get(self, request, organization, member_id):
        """Currently only returns allowed invite roles for member invite"""

        try:
            member = self._get_member(request, organization, member_id)
        except OrganizationMember.DoesNotExist:
            raise ResourceDoesNotExist

        _, allowed_roles = get_allowed_roles(request, organization, member)

        allowed_roles = [{
            'role': serialize(r, serializer=RoleSerializer()),
            'allowed': r in allowed_roles
        } for r in roles.get_all()]

        context = serialize(member, )

        context['allowed_roles'] = allowed_roles

        return Response(context)