def post(self): if User_tool.check_before_start("createCar", self) >= 0: data = json.loads(self.request.body) if "Bluetooth_MAC" in data: new_car = Car(name=data["Name"], latitude="0", longitude="0", timestamp=str(datetime.datetime.now()), email=data["Email"], bluetooth_MAC=data["Bluetooth_MAC"], bluetooth_name=data["Bluetooth_name"], brand=data["Brand"]) else: new_car = Car(name=data["Name"], latitude="0", longitude="0", timestamp=str(datetime.datetime.now()), email=data["Email"], brand=data["Brand"]) new_car.put() right = StatusReturn(4, "createCar", new_car.key.id()) self.response.write(right.print_result())
def post(self): if User_tool.check_before_start("createCar", self) >= 0: dati = json.loads(self.request.body) car_data = dati["Car"] user_data = dati["User"] bluetooth_MAC = "" bluetooth_name = "" register = "" uuid = "" bmaj = "" bmin = "" marker_color = None if "Bluetooth_MAC" in car_data: bluetooth_MAC = car_data["Bluetooth_MAC"] if "Bluetooth_Name" in car_data: bluetooth_name = car_data["Bluetooth_Name"] if "Register" in car_data: register = car_data["Register"] if "Marker_Color" in car_data: marker_color = car_data["Marker_Color"] new_car = Car(name=car_data["Name"], latitude="0", longitude="0", timestamp=str(datetime.datetime.now()), email=user_data["Email"], bluetooth_MAC=bluetooth_MAC, bluetooth_name=bluetooth_name, brand=car_data["Brand"], register=register, isParked=False, lastdriver=user_data["Email"], uuid=uuid, marker_color=marker_color) new_car = new_car.put() list_user = car_data["Users"] searchuser = User.static_querySearch_email(user_data["Email"]) for user in searchuser: if static_variable.DEBUG: logging.debug(user.key.id()) new_contact_car = User_car(id_user=user.key.id(), id_car=(new_car.id())) new_contact_car.put() for user in list_user: userEmail = user["Email"] user_key = User.is_user_check(userEmail) if user_key == 0: new_user = User(id_android=None, code=0, temp_code=0, email=userEmail, nickname=None, is_user=0) temp_user_key = new_user.put() user_key = temp_user_key.id() if User_car.check_user_exist(user_key, new_car.id()) > 0: new_contact_car = User_car(id_user=user_key, id_car=new_car.id()) new_contact_car.put() right = StatusReturn(4, "createCar", new_car.id()) self.response.write(right.print_result())
def post(self): if User_tool.check_before_start("createCar", self) >= 0: dati = json.loads(self.request.body) car_data = dati["Car"] user_data = dati["User"] bluetooth_MAC = "" bluetooth_name = "" register = "" uuid = "" bmaj = "" bmin = "" marker_color = None if "Bluetooth_MAC" in car_data: bluetooth_MAC = car_data["Bluetooth_MAC"] if "Bluetooth_Name" in car_data: bluetooth_name = car_data["Bluetooth_Name"] if "Register" in car_data: register = car_data["Register"] if "Marker_Color" in car_data: marker_color = car_data["Marker_Color"] new_car = Car(name=car_data["Name"], latitude="0", longitude="0", timestamp=str(datetime.datetime.now()), email=user_data["Email"], bluetooth_MAC=bluetooth_MAC, bluetooth_name=bluetooth_name, brand=car_data["Brand"], register=register, isParked=False, lastdriver=user_data["Email"], uuid=uuid, marker_color=marker_color) new_car = new_car.put() list_user = car_data["Users"] searchuser = User.static_querySearch_email(user_data["Email"]) for user in searchuser: if static_variable.DEBUG: logging.debug(user.key.id()) new_contact_car = User_car(id_user=user.key.id(), id_car=(new_car.id())) new_contact_car.put() for user in list_user: userEmail = user["Email"] user_key = User.is_user_check(userEmail) if user_key == 0: new_user = User(id_android=None, code=0, temp_code=0, email=userEmail, nickname=None, is_user=0) temp_user_key = new_user.put() user_key = temp_user_key.id() if User_car.check_user_exist(user_key, new_car.id()) > 0: new_contact_car = User_car(id_user=user_key, id_car=new_car.id()) new_contact_car.put() right = StatusReturn(4, "createCar", new_car.id()) self.response.write(right.print_result())