コード例 #1
0
ファイル: rubeus.py プロジェクト: GloriaaLi/osf.io
    def collect_all_registrations_smart_folder(self):
        from website.project.model import Node
        all_my_registrations = Node.find_for_user(
            self.auth.user,
            (
                Q('category', 'eq', 'project') &
                Q('is_deleted', 'eq', False) &
                Q('is_registration', 'eq', True) &
                Q('is_folder', 'eq', False) &
                # parent is not in the nodes list
                Q('__backrefs.parent.node.nodes', 'eq', None)
            )
        )
        comps = Node.find_for_user(
            self.auth.user,
            (
                # components only
                Q('category', 'ne', 'project') &
                # parent is not in the nodes list
                Q('__backrefs.parent.node.nodes', 'nin', all_my_registrations.get_keys()) &
                # exclude deleted nodes
                Q('is_deleted', 'eq', False) &
                # exclude registrations
                Q('is_registration', 'eq', True)
            )

        )
        children_count = all_my_registrations.count() + comps.count()
        return self.make_smart_folder(ALL_MY_REGISTRATIONS_NAME, ALL_MY_REGISTRATIONS_ID, children_count)
コード例 #2
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))
コード例 #3
0
ファイル: utils.py プロジェクト: GloriaaLi/osf.io
def get_projects(user):
    """Return a list of user's projects, excluding registrations and folders."""
    return list(
        Node.find_for_user(
            user,
            (Q('category', 'eq', 'project') & Q('is_registration', 'eq', False)
             & Q('is_deleted', 'eq', False) & Q('is_folder', 'eq', False))))
コード例 #4
0
ファイル: utils.py プロジェクト: lambroisie/osf.io
def get_projects(user):
    """Return a list of user's projects, excluding registrations and folders."""
    # Note: If the user is a contributor to a child (but does not have access to the parent), it will be
    # excluded from this view
    # Avoid circular import
    from website.project.utils import TOP_LEVEL_PROJECT_QUERY

    return Node.find_for_user(user, subquery=TOP_LEVEL_PROJECT_QUERY)
コード例 #5
0
ファイル: views.py プロジェクト: cwisecarver/osf.io
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)
コード例 #6
0
ファイル: utils.py プロジェクト: HalcyonChimera/osf.io
def get_projects(user):
    """Return a list of user's projects, excluding registrations and folders."""
    # Note: If the user is a contributor to a child (but does not have access to the parent), it will be
    # excluded from this view
    # Avoid circular import
    from website.project.utils import TOP_LEVEL_PROJECT_QUERY

    return Node.find_for_user(user, subquery=TOP_LEVEL_PROJECT_QUERY)
コード例 #7
0
ファイル: utils.py プロジェクト: lambroisie/osf.io
def get_public_projects(user):
    """Return a list of a user's public projects."""
    # Avoid circular import
    from website.project.utils import TOP_LEVEL_PROJECT_QUERY

    return Node.find_for_user(user,
                              subquery=(Q('is_public', 'eq', True)
                                        & TOP_LEVEL_PROJECT_QUERY))
コード例 #8
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))
コード例 #9
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(
        Node.find_for_user(
            user, (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)
コード例 #10
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)
コード例 #11
0
ファイル: views.py プロジェクト: fredtoh/osf.io
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))
コード例 #12
0
ファイル: utils.py プロジェクト: KAsante95/osf.io
def get_projects(user):
    """Return a list of user's projects, excluding registrations and folders."""
    return list(Node.find_for_user(
        user,
        (
            Q('category', 'eq', 'project') &
            Q('is_registration', 'eq', False) &
            Q('is_deleted', 'eq', False) &
            Q('is_folder', 'eq', False)
        )
    ))
コード例 #13
0
ファイル: utils.py プロジェクト: HalcyonChimera/osf.io
def get_public_projects(user):
    """Return a list of a user's public projects."""
    # Avoid circular import
    from website.project.utils import TOP_LEVEL_PROJECT_QUERY

    return Node.find_for_user(
        user,
        subquery=(
            Q('is_public', 'eq', True) &
            TOP_LEVEL_PROJECT_QUERY
        )
    )
コード例 #14
0
ファイル: views.py プロジェクト: KAsante95/osf.io
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))
コード例 #15
0
ファイル: views.py プロジェクト: DanielSBrown/osf.io
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))
コード例 #16
0
ファイル: views.py プロジェクト: KAsante95/osf.io
def get_public_components(uid=None, user=None):
    user = user or User.load(uid)
    # TODO: This should use User.visible_contributor_to?

    nodes = list(
        Node.find_for_user(
            user,
            (
                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
ファイル: views.py プロジェクト: DanielSBrown/osf.io
def get_public_components(uid=None, user=None):
    user = user or User.load(uid)
    # TODO: This should use User.visible_contributor_to?

    nodes = list(
        Node.find_for_user(
            user,
            (
                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)