示例#1
0
    def test_none_user(self):
        request = RequestFactory().get("/")
        request.session = {}
        request.access = NoAccess()
        result = self.endpoint.get_projects(request, self.org)
        assert [] == result

        request.user = None
        result = self.endpoint.get_projects(request, self.org)
        assert [] == result
示例#2
0
def serialize_detailed_org(context, obj):
    if "request" in context:
        user = context["request"].user
        access = from_user(user, obj)
    else:
        user = None
        access = NoAccess()

    context = serialize_func(
        obj, user, DetailedOrganizationSerializerWithProjectsAndTeams(), access=access
    )

    return convert_to_json(context)
示例#3
0
def serialize_detailed_org(context, obj):
    if 'request' in context:
        user = context['request'].user
        access = from_user(user, obj)
    else:
        user = None
        access = NoAccess()

    context = serialize_func(obj,
                             user,
                             DetailedOrganizationSerializer(),
                             access=access)

    return convert_to_json(context)