def _reindex_proposals(catalogs: ICatalogsService, root: IPool): proposals_2015 = get_most_rated_proposals( root, min_rate=0, proposal_interface=IMercatorProposalVersion) proposals_2016 = get_most_rated_proposals( root, min_rate=0, proposal_interface=IMercatorProposal) proposals = proposals_2015 + proposals_2016 for proposal in proposals: catalogs.reindex_index(proposal, 'rates')
def _delete_rate_items(catalogs: ICatalogsService, user: IUser): query = search_query._replace( interfaces=IRate, references=[(None, IMetadata, 'creator', user)], ) user_rates = catalogs.search(query).elements for rate in user_rates: _delete(rate)
def is_catalogish(context: object, request: IRequest) -> bool: """Return true if context is catalog or root.""" if IRoot.providedBy(context): return True elif ICatalogsService.providedBy(context): return True elif ICatalog.providedBy(context): return True else: return False
def _is_arbitrary_filter(name: str, catalogs: ICatalogsService) -> bool: """ Return True if `name' refers to an public arbitrary catalog index. """ if name.startswith('private_'): return False else: index = catalogs.get_index(name) return index is not None
def _search_for_interfaces(catalogs: ICatalogsService, interfaces: (IInterface)) -> [IResource]: query = search_query._replace(interfaces=interfaces) resources = catalogs.search(query).elements return resources
def _reindex_proposals(catalogs: ICatalogsService, root: IPool): proposals = get_most_rated_proposals(root, min_rate=0) for proposal in proposals: catalogs.reindex_index(proposal, 'rates')
def _search_for_interfaces(catalogs: ICatalogsService, interfaces: (IInterface)) -> [IResource]: query = search_query._replace(interfaces=interfaces, resolve=True) resources = catalogs.search(query).elements return resources