def get_all_registrations_smart_folder(auth, **kwargs): # TODO: Unit tests user = auth.user contributed = user.node__contributed nodes = contributed.find( 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)).sort('-title') parents_to_exclude = contributed.find( Q('category', 'eq', 'project') & Q('is_deleted', 'eq', False) & Q('is_registration', 'eq', True) & Q('is_folder', 'eq', False)) comps = contributed.find( Q('is_folder', 'eq', False) & # parent is not in the nodes list Q('__backrefs.parent.node.nodes', 'nin', parents_to_exclude.get_keys()) & # is not in the nodes list Q('_id', 'nin', nodes.get_keys()) & # exclude deleted nodes Q('is_deleted', 'eq', False) & # exclude registrations Q('is_registration', 'eq', True)) return_value = [ rubeus.to_project_root(comp, auth, **kwargs) for comp in comps ] return_value.extend( [rubeus.to_project_root(node, auth, **kwargs) for node in nodes]) return return_value
def get_all_projects_smart_folder(auth, **kwargs): # TODO: Unit tests user = auth.user contributed = user.node__contributed nodes = contributed.find( Q("is_deleted", "eq", False) & Q("is_registration", "eq", False) & Q("is_folder", "eq", False) ).sort("-title") keys = nodes.get_keys() return [rubeus.to_project_root(node, auth, **kwargs) for node in nodes if node.parent_id not in keys]
def get_all_registrations_smart_folder(auth, **kwargs): # TODO: Unit tests user = auth.user contributed = user.node__contributed nodes = contributed.find( Q('is_deleted', 'eq', False) & Q('is_registration', 'eq', True) & Q('is_folder', 'eq', False) ).sort('-title') keys = nodes.get_keys() return [rubeus.to_project_root(node, auth, **kwargs) for node in nodes if node.parent_id not in keys]
def get_all_registrations_smart_folder(auth, **kwargs): # TODO: Unit tests user = auth.user contributed = user.node__contributed nodes = contributed.find( Q("is_deleted", "eq", False) & Q("is_registration", "eq", True) & Q("is_folder", "eq", False) ).sort("-title") # Note(hrybacki): is_retracted and pending_embargo are property methods # and cannot be directly queried nodes = filter(lambda node: not node.is_retracted and not node.pending_embargo, nodes) keys = [node._id for node in nodes] return [rubeus.to_project_root(node, auth, **kwargs) for node in nodes if node.ids_above.isdisjoint(keys)]
def get_all_projects_smart_folder(auth, **kwargs): # TODO: Unit tests user = auth.user contributed = user.node__contributed nodes = contributed.find( Q('category', 'eq', 'project') & Q('is_deleted', 'eq', False) & Q('is_registration', 'eq', False) & Q('is_folder', 'eq', False) & # parent is not in the nodes list Q('__backrefs.parent.node.nodes', 'eq', None) ).sort('-title') parents_to_exclude = contributed.find( Q('category', 'eq', 'project') & Q('is_deleted', 'eq', False) & Q('is_registration', 'eq', False) & Q('is_folder', 'eq', False) ) comps = contributed.find( Q('is_folder', 'eq', False) & # parent is not in the nodes list Q('__backrefs.parent.node.nodes', 'nin', parents_to_exclude.get_keys()) & # is not in the nodes list Q('_id', 'nin', nodes.get_keys()) & # exclude deleted nodes Q('is_deleted', 'eq', False) & # exclude registrations Q('is_registration', 'eq', False) ) return_value = [rubeus.to_project_root(node, auth, **kwargs) for node in comps] return_value.extend([rubeus.to_project_root(node, auth, **kwargs) for node in nodes]) return return_value
def get_dashboard(auth, nid=None, **kwargs): user = auth.user if nid is None: node = find_dashboard(user) dashboard_projects = [rubeus.to_project_root(node, auth, **kwargs)] return_value = {'data': dashboard_projects} elif nid == ALL_MY_PROJECTS_ID: return_value = {'data': get_all_projects_smart_folder(**kwargs)} elif nid == ALL_MY_REGISTRATIONS_ID: return_value = {'data': get_all_registrations_smart_folder(**kwargs)} else: node = Node.load(nid) dashboard_projects = rubeus.to_project_hgrid(node, auth, **kwargs) return_value = {'data': dashboard_projects} return return_value
def get_all_projects_smart_folder(auth, **kwargs): # TODO: Unit tests user = auth.user contributed = Node.find_for_user( user, subquery=( Q('is_deleted', 'eq', False) & Q('is_registration', 'eq', False) & Q('is_folder', 'eq', False) ) ) nodes = contributed.sort('title') keys = nodes.get_keys() return [rubeus.to_project_root(node, auth, **kwargs) for node in nodes if node.parent_id not in keys]
def get_all_registrations_smart_folder(auth, **kwargs): # TODO: Unit tests user = auth.user contributed = user.node__contributed nodes = contributed.find( Q('is_deleted', 'eq', False) & Q('is_registration', 'eq', True) & Q('is_folder', 'eq', False) ).sort('-title') # Note(hrybacki): is_retracted and is_pending_embargo are property methods # and cannot be directly queried nodes = filter(lambda node: not node.is_retracted and not node.is_pending_embargo, nodes) keys = [node._id for node in nodes] return [rubeus.to_project_root(node, auth, **kwargs) for node in nodes if node.ids_above.isdisjoint(keys)]
def get_dashboard(auth, nid=None, **kwargs): user = auth.user if nid is None: node = find_dashboard(user) dashboard_projects = [rubeus.to_project_root(node, auth, **kwargs)] return_value = {'data': dashboard_projects} elif nid == ALL_MY_PROJECTS_ID: return_value = {'data': get_all_projects_smart_folder(**kwargs)} elif nid == ALL_MY_REGISTRATIONS_ID: return_value = {'data': get_all_registrations_smart_folder(**kwargs)} else: node = Node.load(nid) dashboard_projects = rubeus.to_project_hgrid(node, auth, **kwargs) return_value = {'data': dashboard_projects} return_value['timezone'] = user.timezone return return_value