Пример #1
0
def get_public_projects(uid=None, user=None):
    user = user or User.load(uid)
    # In future redesign, should be limited for users with many projects / components
    nodes = Node.find_for_user(user,
                               subquery=(TOP_LEVEL_PROJECT_QUERY
                                         & Q('is_public', 'eq', True)))
    return _render_nodes(list(nodes))
Пример #2
0
def get_forks(auth, **kwargs):
    node_to_use = kwargs['node'] or kwargs['project']
    forks = node_to_use.node__forked.find(
        Q('is_deleted', 'eq', False) &
        Q('is_registration', 'eq', False)
    )
    return _render_nodes(forks, auth)
Пример #3
0
def get_forks(auth, **kwargs):
    node_to_use = kwargs['node'] or kwargs['project']
    forks = node_to_use.node__forked.find(
        Q('is_deleted', 'eq', False) &
        Q('is_registration', 'eq', False)
    )
    return _render_nodes(forks, auth)
Пример #4
0
def get_registrations(auth, node, **kwargs):
    # get all undeleted registrations, including archiving
    sorted_registrations = node.registrations_all.sort('-registered_date')
    undeleted_registrations = [
        n for n in sorted_registrations if not n.is_deleted
    ]
    return _render_nodes(undeleted_registrations, auth)
Пример #5
0
def get_public_projects(uid=None, user=None):
    user = user or User.load(uid)
    return _render_nodes(
        list(
            user.node__contributed.find(
                (Q('category', 'eq', 'project') & Q('is_public', 'eq', True)
                 & Q('is_registration', 'eq', False)
                 & Q('is_deleted', 'eq', False)))))
Пример #6
0
def get_children(auth, node, **kwargs):
    user = auth.user
    if request.args.get("permissions"):
        perm = request.args["permissions"].lower().strip()
        nodes = [each for each in node.nodes if perm in each.get_permissions(user) and not each.is_deleted]
    else:
        nodes = [each for each in node.nodes if not each.is_deleted]
    return _render_nodes(nodes, auth)
Пример #7
0
def get_public_components(uid=None, user=None):
    user = user or User.load(uid)
    # TODO: This should use User.visible_contributor_to?
    # In future redesign, should be limited for users with many projects / components
    nodes = list(
        Node.find_for_user(user, subquery=(PROJECT_QUERY & Q("parent_node", "ne", None) & Q("is_public", "eq", True)))
    )
    return _render_nodes(nodes, show_path=True)
Пример #8
0
def get_public_components(uid=None, user=None):
    user = user or User.load(uid)
    # TODO: This should use User.visible_contributor_to?
    nodes = list(
        user.node__contributed.find(
            (Q('category', 'ne', 'project') & Q('is_public', 'eq', True)
             & Q('is_registration', 'eq', False)
             & Q('is_deleted', 'eq', False))))
    return _render_nodes(nodes, show_path=True)
Пример #9
0
def get_public_projects(uid=None, user=None):
    user = user or User.load(uid)

    nodes = Node.find_for_user(
        user,
        subquery=(Q('category', 'eq', 'project') & Q('is_public', 'eq', True)
                  & Q('is_registration', 'eq', False)
                  & Q('is_deleted', 'eq', False)))
    return _render_nodes(list(nodes))
Пример #10
0
def get_public_components(uid=None, user=None):
    user = user or User.load(uid)
    return _render_nodes([
        node
        for node in user.node__contributed
        if node.category != 'project'
        and node.is_public
        and not node.is_registration
        and not node.is_deleted
    ])
Пример #11
0
def get_public_components(uid=None, user=None):
    user = user or User.load(uid)
    return _render_nodes([
        node
        for node in user.node__contributed
        if node.category != 'project'
        and node.is_public
        and not node.is_registration
        and not node.is_deleted
    ])
Пример #12
0
def get_public_components(uid=None, user=None):
    user = user or User.load(uid)
    # TODO: This should use User.visible_contributor_to?
    # In future redesign, should be limited for users with many projects / components
    nodes = list(
        Node.find_for_user(
            user,
            subquery=(PROJECT_QUERY & Q('parent_node', 'ne', None)
                      & Q('is_public', 'eq', True))))
    return _render_nodes(nodes, show_path=True)
Пример #13
0
def get_public_projects(uid=None, user=None):
    user = user or User.load(uid)
    # In future redesign, should be limited for users with many projects / components
    nodes = Node.find_for_user(
        user,
        subquery=(
            TOP_LEVEL_PROJECT_QUERY &
            Q('is_public', 'eq', True)
        )
    )
    return _render_nodes(list(nodes))
Пример #14
0
def get_children(auth, node, **kwargs):
    user = auth.user
    if request.args.get('permissions'):
        perm = request.args['permissions'].lower().strip()
        nodes = [
            each for each in node.nodes
            if perm in each.get_permissions(user) and not each.is_deleted
        ]
    else:
        nodes = [each for each in node.nodes if not each.is_deleted]
    return _render_nodes(nodes, auth)
Пример #15
0
def get_children(auth, **kwargs):
    user = auth.user
    node_to_use = kwargs['node'] or kwargs['project']
    if request.args.get('permissions'):
        perm = request.args['permissions'].lower().strip()
        nodes = [
            node for node in node_to_use.nodes
            if perm in node.get_permissions(user) and not node.is_deleted
        ]
    else:
        nodes = [node for node in node_to_use.nodes if not node.is_deleted]
    return _render_nodes(nodes, auth)
Пример #16
0
def get_public_components(uid=None, user=None):
    user = user or User.load(uid)
    # TODO: This should use User.visible_contributor_to?
    nodes = list(user.node__contributed.find(
        (
            Q('category', 'ne', 'project') &
            Q('is_public', 'eq', True) &
            Q('is_registration', 'eq', False) &
            Q('is_deleted', 'eq', False)
        )
    ))
    return _render_nodes(nodes, show_path=True)
Пример #17
0
def get_public_projects(uid=None, user=None):
    user = user or User.load(uid)
    return _render_nodes(
        list(user.node__contributed.find(
            (
                Q('category', 'eq', 'project') &
                Q('is_public', 'eq', True) &
                Q('is_registration', 'eq', False) &
                Q('is_deleted', 'eq', False)
            )
        ))
    )
Пример #18
0
def get_children(auth, **kwargs):
    user = auth.user
    node_to_use = kwargs['node'] or kwargs['project']
    if request.args.get('permissions'):
        perm = request.args['permissions'].lower().strip()
        nodes = [node for node in node_to_use.nodes if perm in node.get_permissions(user) and not node.is_deleted]
    else:
        nodes = [
            node
            for node in node_to_use.nodes
            if not node.is_deleted
        ]
    return _render_nodes(nodes, auth)
Пример #19
0
def get_public_projects(uid=None, user=None):
    user = user or User.load(uid)

    nodes = Node.find_for_user(
        user,
        subquery=(
            Q("category", "eq", "project")
            & Q("is_public", "eq", True)
            & Q("is_registration", "eq", False)
            & Q("is_deleted", "eq", False)
        ),
    )
    return _render_nodes(list(nodes))
Пример #20
0
def get_public_projects(uid=None, user=None):
    user = user or User.load(uid)

    nodes = Node.find_for_user(
        user,
        subquery=(
            Q('category', 'eq', 'project') &
            Q('is_public', 'eq', True) &
            Q('is_registration', 'eq', False) &
            Q('is_deleted', 'eq', False)
        )
    )
    return _render_nodes(list(nodes))
Пример #21
0
def get_public_projects(uid=None, user=None):
    user = user or User.load(uid)
    return _render_nodes(
        list(
            user.node__contributed.find(
                (
                    Q("category", "eq", "project")
                    & Q("is_public", "eq", True)
                    & Q("is_registration", "eq", False)
                    & Q("is_deleted", "eq", False)
                )
            )
        )
    )
Пример #22
0
def get_public_components(uid=None, user=None):
    user = user or User.load(uid)
    # TODO: This should use User.visible_contributor_to?
    nodes = list(
        user.node__contributed.find(
            (
                Q("category", "ne", "project")
                & Q("is_public", "eq", True)
                & Q("is_registration", "eq", False)
                & Q("is_deleted", "eq", False)
            )
        )
    )
    return _render_nodes(nodes, show_path=True)
Пример #23
0
def get_readable_descendants(auth, node, **kwargs):
    descendants = []
    for child in node.nodes:
        if request.args.get('permissions'):
            perm = request.args['permissions'].lower().strip()
            if perm not in child.get_permissions(auth.user):
                continue
        if child.is_deleted:
            continue
        elif child.can_view(auth):
            descendants.append(child)
        elif not child.primary:
            if node.has_permission(auth.user, 'write'):
                descendants.append(child)
            continue
        else:
            for descendant in child.find_readable_descendants(auth):
                descendants.append(descendant)
    return _render_nodes(descendants, auth)
Пример #24
0
def get_readable_descendants(auth, node, **kwargs):
    descendants = []
    for child in node.nodes:
        if request.args.get('permissions'):
            perm = request.args['permissions'].lower().strip()
            if perm not in child.get_permissions(auth.user):
                continue
        if child.is_deleted:
            continue
        elif child.can_view(auth):
            descendants.append(child)
        elif not child.primary:
            if node.has_permission(auth.user, 'write'):
                descendants.append(child)
            continue
        else:
            for descendant in child.find_readable_descendants(auth):
                descendants.append(descendant)
    return _render_nodes(descendants, auth)
Пример #25
0
def get_forks(auth, node, **kwargs):
    forks = node.node__forked.find(
        Q('is_deleted', 'eq', False) & Q('is_registration', 'eq', False))
    return _render_nodes(forks, auth)
Пример #26
0
def get_forks(auth, node, **kwargs):
    fork_list = node.forks.sort('-forked_date')
    return _render_nodes(nodes=fork_list, auth=auth)
Пример #27
0
def get_registrations(auth, **kwargs):
    node_to_use = kwargs['node'] or kwargs['project']
    registrations = node_to_use.node__registrations
    return _render_nodes(registrations, auth)
Пример #28
0
def get_forks(auth, node, **kwargs):
    forks = node.node__forked.find(
        Q('is_deleted', 'eq', False) &
        Q('is_registration', 'eq', False)
    )
    return _render_nodes(forks, auth)
Пример #29
0
def get_registrations(auth, node, **kwargs):
    registrations = [
        n for n in reversed(node.node__registrations) if not n.is_deleted
    ]  # get all registrations, including archiving
    return _render_nodes(registrations, auth)
Пример #30
0
def get_forks(auth, node, **kwargs):
    fork_list = sorted(node.forks,
                       key=lambda fork: fork.forked_date,
                       reverse=True)
    return _render_nodes(nodes=fork_list, auth=auth)
Пример #31
0
def get_forks(auth, node, **kwargs):
    return _render_nodes(nodes=node.forks, auth=auth)
Пример #32
0
def get_registrations(auth, node, **kwargs):
    registrations = node.node__registrations
    return _render_nodes(registrations, auth)
Пример #33
0
def get_registrations(auth, node, **kwargs):
    # get all undeleted registrations, including archiving
    sorted_registrations = node.registrations_all.sort('-registered_date')
    undeleted_registrations = [n for n in sorted_registrations if not n.is_deleted]
    return _render_nodes(undeleted_registrations, auth)
Пример #34
0
def get_forks(auth, node, **kwargs):
    return _render_nodes(nodes=node.forks, auth=auth)
Пример #35
0
def get_registrations(auth, node, **kwargs):
    registrations = [n for n in reversed(node.node__registrations) if not n.is_deleted]  # get all registrations, including archiving
    return _render_nodes(registrations, auth)
Пример #36
0
def get_forks(auth, node, **kwargs):
    fork_list = sorted(node.forks, key=lambda fork: fork.forked_date, reverse=True)
    return _render_nodes(nodes=fork_list, auth=auth)
Пример #37
0
def get_registrations(auth, **kwargs):
    node_to_use = kwargs['node'] or kwargs['project']
    registrations = node_to_use.node__registrations
    return _render_nodes(registrations, auth)
Пример #38
0
def get_registrations(auth, node, **kwargs):
    registrations = node.node__registrations
    return _render_nodes(registrations, auth)
Пример #39
0
def get_forks(auth, node, **kwargs):
    fork_list = node.forks.sort('-forked_date')
    return _render_nodes(nodes=fork_list, auth=auth)