Example #1
0
    def save(self, request):
        newBook = Booking()
        newBook.customer = request.user
        newBook.payment_type = request.POST.get("payment_type")
        newBook.price = request.POST.get("price")
        newBook.total_distance = request.POST.get("total_distance")
        newBook.save()
        self.validated_data['book_id'] = newBook.id

        pickupAddress = Address()
        pickupAddress.title = request.POST.get("pickup_address_title")
        pickupAddress.description = request.POST.get(
            "pickup_address_description")
        pickupAddress.longitude = request.POST.get("pickup_address_longitude")
        pickupAddress.latitude = request.POST.get("pickup_address_latitude")
        pickupAddress.is_pickup_loc = True
        pickupAddress.booking = newBook
        pickupAddress.save()

        arrivalAddress = Address()
        arrivalAddress.title = request.POST.get("arrival_address_title")
        arrivalAddress.description = request.POST.get(
            "arrival_address_description")
        arrivalAddress.longitude = request.POST.get(
            "arrival_address_longitude")
        arrivalAddress.latitude = request.POST.get("arrival_address_latitude")
        arrivalAddress.is_arrival_loc = True
        arrivalAddress.booking = newBook
        arrivalAddress.save()

        #  find nearest userInfo
        # nearestDriverUserInfo = findNearestDriver(latitude=pickupAddress.latitude , longitude=pickupAddress.longitude , filterMaxDistance=10000)
        # newBook.driver = nearestDriverUserInfo.user
        return newBook
Example #2
0
 def create_booking(self, model: CreateBookingDto):
     booking = Booking()
     booking.booking_reference = model.booking_reference
     booking.flight_id = model.flight_id
     booking.take_off_point = model.take_off_point
     booking.price = model.price
     booking.take_off_time = model.take_off_time
     booking.destination = model.destination
     booking.flight_class = model.flight_class
     booking.name = model.name
     booking.phone = model.phone
     booking.email = model.email
     booking.address = model.address
     booking.save()