def delete_car(car_id): try: response.status = 200 result = car_service.delete_by_id(car_id) return commons_utilitaire.json_bool_response(result) except TypeError as e: print(e) return commons_utilitaire.error_handler(400, invalid_parameters, response)
def update_car(): try: response.status = 200 car = commons_utilitaire.get_record_from_body(request, Car) result = car_service.update(car) return commons_utilitaire.json_bool_response(result) except TypeError as e: print(e) return commons_utilitaire.error_handler(400, invalid_parameters, response)
def delete(car_id): table = "../cars" result = car_service.delete_by_id(car_id) message = commons_utilitaire.json_bool_response(result) test = list(message.values()) if test[0] == 200: footer = template('footer.tpl', table=table) return {"body": test[1], "footer": footer} else: return error500
def create_driver(): try: response.status = 200 driver = commons_utilitaire.get_record_from_body(request, Driver) result = driver_service.create(driver) return commons_utilitaire.json_bool_response(result) except TypeError as e: print(e) return commons_utilitaire.error_handler(400, invalid_parameters, response)
def delete(driver_id): table = "../drivers" result = driver_service.delete_by_id(driver_id) message = commons_utilitaire.json_bool_response(result) test = list(message.values()) if test[0] == 200: footer = template('footer.tpl', table=table) return {"body": test[1], "footer": footer} else: return error500
def create(): table = "../drivers" driver = Driver() driver.driver_id = request.forms.get('driver_id') driver.driver_name = request.forms.get('driver_name') entity = driver_service.create(driver) message = commons_utilitaire.json_bool_response(entity) test = list(message.values()) if test[0] == 200: footer = template('footer.tpl', table=table) return {"body": test[1], "footer": footer} else: return error500
def update(): table = "../cars" car = Car() car.car_id = request.forms.get('car_id') car.car_name = request.forms.get('car_name') car.driver_id = request.forms.get('driver_id') entity = car_service.update(car) message = commons_utilitaire.json_bool_response(entity) test = list(message.values()) if test[0] == 200: footer = template('footer.tpl', table=table) return {"body": test[1], "footer": footer} else: return error500
def update(): table = "../cars" car = Car() car.car_id = request.forms.get('car_id') car.car_name = request.forms.get('car_name') car.driver_id = request.forms.get('driver_id') entity = car_service.update(car) message = commons_utilitaire.json_bool_response(entity) test = list(message.values()) if test[0] == 200: footer = template('footer.tpl', table=table) return {"body": test[1], "footer": footer} else: return error500