Esempio n. 1
0
def find_data_hs(code):
    data = force_json(request)

    rb = RefBookRegistry.get(code)

    ret_data = rb.meta.__json__()
    ret_data['data'] = rb.find_one(prepare_find_params(data))
    return ret_data
Esempio n. 2
0
def search_city_country(value, limit=None):
    rb = RefBookRegistry.get(CITY_CODE)
    find = {
        'is_actual': '1',
        '$or': [{
            'name': prepare_find_params(value)
        }, {
            'identcode': value
        }]
    }
    cities = rb.find(find, 'level', limit)
    result = _set_cities_parents(cities)
    return result
Esempio n. 3
0
def search_street(city_code, value=None, limit=None):
    rb = RefBookRegistry.get(STREET_CODE)
    find = {'identparent': city_code, 'is_actual': '1'}
    if value:
        prepared = prepare_find_params(value)
        find.update({
            '$or': [{
                'name': prepared
            }, {
                'fulltype': prepared
            }, {
                'shorttype': prepared
            }, {
                'identcode': value
            }]
        })
    result = rb.find(find, 'name', limit)
    return list(result)
Esempio n. 4
0
def find_data(code):
    data = force_json(request)
    rb = RefBookRegistry.get(code)
    find = prepare_find_params(data)
    return rb.find(find)