示例#1
0
def harvest_source_list(context, data_dict):
    '''
    TODO: Use package search
    '''

    check_access('harvest_source_list', context, data_dict)

    model = context['model']
    session = context['session']
    user = context.get('user', '')

    sources = _get_sources_for_user(context, data_dict)

    context.update({'detailed': False})
    return [harvest_source_dictize(source, context) for source in sources]
示例#2
0
def harvest_source_for_a_dataset(context, data_dict):
    '''
    TODO: Deprecated, harvest source id is added as an extra to each dataset
    automatically
    '''
    '''For a given dataset, return the harvest source that
    created or last updated it, otherwise NotFound.'''

    model = context['model']
    session = context['session']

    dataset_id = data_dict.get('id')

    query = session.query(HarvestSource)\
        .join(HarvestObject)\
        .filter_by(package_id=dataset_id)\
        .order_by(HarvestObject.gathered.desc())
    source = query.first()  # newest

    if not source:
        raise NotFound

    return harvest_source_dictize(source, context)