Пример #1
0
    def post(self):
        if User_tool.check_before_start("updatePosition", self) >= 0:
            data = json.loads(self.request.body)
            latitude = data["Latitude"]
            longitude = data["Longitude"]
            id_car = data["ID_car"]
            try:
                Car.update_position_ID(id_car, latitude, longitude)

                # push_class.send_post_request("APA91bFKpc1XNokg3Gv9GTWI49oE-UXe-ED6JMam2YPdAYG23yJf_P3c7Tl_55f9iECuhSNVa86PfZfcZ4knQ2VzFuBy_lNrq5_DLRHcghMkTQtRl9jyCbL6tV5TquDrse-dMQlGx9HKDLbtCNwEhGEFVeWXQH9EBjCt-VewSitHtgk2BxIB-w20ZLZtz2MCGAqRnTKD8B5n")

                temp_car_group = Car_group.getGroupFromCar(long(id_car))
                for group_result in temp_car_group:
                    list_user = User_group.getUserFromGroup(group_result.id_group)
                    result_id_android = []
                    for user_result in list_user:
                        temp_user = User.get_user_by_id(user_result.id_user)
                        if temp_user.email != data["Email"]:
                            if temp_user.is_user == 1:
                                logging.debug("Indirizzo email utente del push: " + str(temp_user.email))
                                result_id_android.append(temp_user.id_android)
                                # push_class.send_push_park(temp_user.id_android)
                            else:
                                Send_email.send_position(temp_user.email, latitude, longitude)
                    if len(result_id_android) > 0:
                        push_class.send_push_park(result_id_android , Car.get_name_id(long(id_car)))

                right = StatusReturn(5, "updatePosition")
                self.response.write(right.print_result())
            except:
                self.error(500)
                error = StatusReturn(8, "updatePosition", str(sys.exc_info()))
                self.response.write(error.print_general_error())
Пример #2
0
    def post(self):
        if User_tool.check_before_start("updatePosition", self) >= 0:
            dati = json.loads(self.request.body)
            user_data = dati["User"]
            temp_user = User.static_querySearch_email(user_data["Email"])

            car_data = dati["Car"]

            timestamp = str(datetime.datetime.utcnow() +
                            datetime.timedelta(hours=1))
            if "Timestamp" in car_data:
                timestamp = car_data["Timestamp"]

            Car.update_position_ID(car_data["ID_car"], car_data["Latitude"],
                                   car_data["Longitude"], user_data["Email"])

            list_user = User_car.getUserFromCar(car_data["ID_car"])

            # Send notification to all user register with this car
            for user in list_user:

                # If the user is not registered inside the application send him an email
                if User.is_registered_check(user.id_user) == 0:
                    if User.get_email_user(user.id_user) != user_data["Email"]:
                        # Send_email.send_position(User.get_email_user(user.id_user), car_data["Latitude"],
                        #                      car_data["Longitude"], user_data["Name"],car_data["Name"])
                        logging.debug("Update position")
                else:
                    if User.get_email_user(user.id_user) != user_data["Email"]:
                        Push_notification.send_push_park(
                            User.get_id_android(user.id_user),
                            car_data["Name"], user_data["Name"],
                            car_data["ID_car"])

            if static_variable.DEBUG:
                logging.debug("Date if car: " + car_data["Name"])

            id_user = temp_user.get().key.id()

            if static_variable.DEBUG:
                logging.debug(timestamp)

            History_park.update_history(id_user, car_data["Latitude"],
                                        car_data["Longitude"], timestamp)

            right = StatusReturn(5, "updatePosition")
            self.response.write(right.print_result())
Пример #3
0
    def post(self):
        if User_tool.check_before_start("updatePosition", self) >= 0:
            dati = json.loads(self.request.body)
            user_data = dati["User"]
            temp_user = User.static_querySearch_email(user_data["Email"])

            car_data = dati["Car"]

            timestamp = str(datetime.datetime.utcnow() + datetime.timedelta(hours=1))
            if "Timestamp" in car_data:
                timestamp = car_data["Timestamp"]

            Car.update_position_ID(car_data["ID_car"], car_data["Latitude"], car_data["Longitude"], user_data["Email"])

            list_user = User_car.getUserFromCar(car_data["ID_car"])

            # Send notification to all user register with this car
            for user in list_user:

                # If the user is not registered inside the application send him an email
                if User.is_registered_check(user.id_user) == 0:
                    if User.get_email_user(user.id_user) != user_data["Email"]:
                       # Send_email.send_position(User.get_email_user(user.id_user), car_data["Latitude"],
                       #                      car_data["Longitude"], user_data["Name"],car_data["Name"])
                        logging.debug("Update position")
                else:
                    if User.get_email_user(user.id_user) != user_data["Email"]:
                        Push_notification.send_push_park(User.get_id_android(user.id_user), car_data["Name"], user_data["Name"], car_data["ID_car"])

            if static_variable.DEBUG:
                logging.debug("Date if car: "+car_data["Name"])

            id_user = temp_user.get().key.id()



            if static_variable.DEBUG:
                logging.debug(timestamp)

            History_park.update_history(id_user,car_data["Latitude"],car_data["Longitude"], timestamp)

            right = StatusReturn(5, "updatePosition")
            self.response.write(right.print_result())