Esempio n. 1
0
def datastore_delete(up_func, context, data_dict):
    lc = ckanapi.LocalCKAN(username=c.user)
    res = lc.action.datastore_search(
        resource_id=data_dict['resource_id'],
        filters=data_dict.get('filters'),
        limit=1,
    )
    result = up_func(context, data_dict)
    act.datastore_activity_create(context,
                                  {'count':res.get('total', 0),
                                   'activity_type': 'deleted datastore',
                                   'resource_id': data_dict['resource_id']}
                                  )
    return result
Esempio n. 2
0
def datastore_delete(up_func, context, data_dict):
    lc = ckanapi.LocalCKAN(username=c.user)
    res = lc.action.datastore_search(
        resource_id=data_dict['resource_id'],
        filters=data_dict.get('filters'),
        limit=1,
    )
    result = up_func(context, data_dict)
    act.datastore_activity_create(context,
                                  {'count':res.get('total', 0),
                                   'activity_type': 'deleted datastore',
                                   'resource_id': data_dict['resource_id']}
                                  )
    return result
Esempio n. 3
0
def datastore_upsert(up_func, context, data_dict):
    lc = ckanapi.LocalCKAN(username=c.user)
    res_data = lc.action.datastore_search(
        resource_id=data_dict['resource_id'],
        filters={},
        limit=1,
    )
    count = res_data.get('total', 0)
    result = up_func(context, data_dict)

    res_data = lc.action.datastore_search(
        resource_id=data_dict['resource_id'],
        filters={},
        limit=1,
    )
    count = res_data.get('total', 0) - count

    act.datastore_activity_create(context, {'count':count,
                                            'activity_type': 'changed datastore',
                                            'resource_id': data_dict['resource_id']}
                                  )
    return result
Esempio n. 4
0
def datastore_upsert(up_func, context, data_dict):
    lc = ckanapi.LocalCKAN(username=c.user)
    res_data = lc.action.datastore_search(
        resource_id=data_dict['resource_id'],
        filters={},
        limit=1,
    )
    count = res_data.get('total', 0)
    result = up_func(context, data_dict)

    res_data = lc.action.datastore_search(
        resource_id=data_dict['resource_id'],
        filters={},
        limit=1,
    )
    count = res_data.get('total', 0) - count

    act.datastore_activity_create(context, {'count':count,
                                            'activity_type': 'changed datastore',
                                            'resource_id': data_dict['resource_id']}
                                  )
    return result