예제 #1
0
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')
예제 #2
0
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')
예제 #3
0
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)
예제 #4
0
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)
예제 #5
0
파일: catalogs.py 프로젝트: liqd/adhocracy3
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
예제 #6
0
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
예제 #7
0
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
예제 #8
0
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
예제 #9
0
def _search_for_interfaces(catalogs: ICatalogsService,
                           interfaces: (IInterface)) -> [IResource]:
    query = search_query._replace(interfaces=interfaces)
    resources = catalogs.search(query).elements
    return resources
예제 #10
0
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')
예제 #11
0
def _search_for_interfaces(catalogs: ICatalogsService,
                           interfaces: (IInterface)) -> [IResource]:
    query = search_query._replace(interfaces=interfaces, resolve=True)
    resources = catalogs.search(query).elements
    return resources
예제 #12
0
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')