-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcar.py
52 lines (42 loc) · 1.49 KB
/
car.py
1
""" omsserver car.py :copyright: (c) 2019 by Pavel Konovalov [email protected] Created on 2019-05-28""" from helper_database import cursor_to_jsonfrom user import get_list_for_carsdef get_list(db): """ Return list of current map markers :param db: :return: """ sql = 'SELECT BIN_TO_UUID(car.guid) as guid, ' \ 'car.name AS name,' \ 'car_type.icon AS icon,' \ 'car_type.icon_back AS icon_back,' \ 'car_type.name AS type_name,' \ 'car.car_id AS car_id,' \ 'car.wialon_id AS wialon_id,' \ 'car.phone as phone,' \ 'mobile_team.name as mobile_team ' \ 'FROM car ' \ 'LEFT JOIN car_type ON car.car_type_id = car_type.id ' \ 'LEFT JOIN mobile_team ON mobile_team.car_id = car.id ' \ 'WHERE car.enabled = 1 order by car.car_id' cursor = db.cursor() cursor.execute(sql) items = cursor_to_json(cursor) for item in items: item['type'] = 'car' if 'icon' in item: item['icon'] = '/static/cars/' + item['icon'] if 'icon_back' in item: item['icon_back'] = '/static/cars/' + item['icon_back'] if 'mobile_team' in item: item['name'] = item['mobile_team'] + ' ' + item['name'] item['icon'] = '/static/cars/' + 'car-Avtomobil_OVB-073315.png' item['icon_back'] = '/static/cars/' + 'car-Avtomobil_OVB-698710.png' items += get_list_for_cars(db) return items