예제 #1
0
파일: rest.py 프로젝트: MarsStirner/vesta
def find_data_hs(code):
    data = APIMixin().parse_request(request)
    obj = Dictionary(code)
    obj_names = DictionaryNames()
    try:
        _dict = obj_names.get_by_code(code)
        result = obj.get_document(prepare_find_params(data))
    except TypeError, e:
        raise InvalidAPIUsage(e.message, status_code=400)
예제 #2
0
def search_city(value, limit=None):
    obj = Dictionary(CITY_CODE)
    find = {
        'is_actual': '1',
        '$or': [{
            'name': prepare_find_params(value)
        }, {
            'identcode': value
        }]
    }
    try:
        cities = obj.get_list(find, 'level', limit)
    except ValueError, e:
        raise InvalidAPIUsage(e.message, status_code=404)
예제 #3
0
def search_street(city_code, value, limit=None):
    obj = Dictionary(STREET_CODE)
    prepared = prepare_find_params(value)
    find = {
        'identparent':
        city_code,
        'is_actual':
        '1',
        '$or': [{
            'name': prepared
        }, {
            'fulltype': prepared
        }, {
            'shorttype': prepared
        }, {
            'identcode': value
        }]
    }
    try:
        result = obj.get_list(find, limit=limit)
    except ValueError, e:
        raise InvalidAPIUsage(e.message, status_code=404)