Exemplo n.º 1
0
    def process_status_update(self, order, data):
        EmergencyOrderStatusUpdate.create_for_order(
            order.pk,
            EmergencyOrderStatusUpdate.STATUS_APPROACHING_ETA,
            zipline_timestamp=data['timestamp'],
            package_number=data['packageNumber'],
            eta_minutes_remaining=data['minutesRemaining'],
            **self.carry_forward_dispatched_data(order, data['packageNumber']))

        return True, {'status': 'success'}
Exemplo n.º 2
0
    def process_status_update(self, order, data):
        EmergencyOrderStatusUpdate.create_for_order(
            order.pk,
            EmergencyOrderStatusUpdate.STATUS_ETA_DELAYED,
            zipline_timestamp=data['timestamp'],
            package_number=data['packageNumber'],
            eta=data['newEta'],
            **self.carry_forward_dispatched_data(order, data['packageNumber']))

        return True, {'status': 'success'}
Exemplo n.º 3
0
    def process_status_update(self, order, data):
        EmergencyOrderStatusUpdate.create_for_order(
            order.pk,
            EmergencyOrderStatusUpdate.STATUS_ETA_DELAYED,
            zipline_timestamp=data['timestamp'],
            package_number=data['packageNumber'],
            eta=data['newEta'],
            **self.carry_forward_dispatched_data(order, data['packageNumber'])
        )

        return True, {'status': 'success'}
Exemplo n.º 4
0
    def process_status_update(self, order, data):
        EmergencyOrderStatusUpdate.create_for_order(
            order.pk,
            EmergencyOrderStatusUpdate.STATUS_APPROACHING_ETA,
            zipline_timestamp=data['timestamp'],
            package_number=data['packageNumber'],
            eta_minutes_remaining=data['minutesRemaining'],
            **self.carry_forward_dispatched_data(order, data['packageNumber'])
        )

        return True, {'status': 'success'}
Exemplo n.º 5
0
    def process_status_update(self, order, data):
        cancelled_in_flight_status = EmergencyOrderStatusUpdate.create_for_order(
            order.pk,
            EmergencyOrderStatusUpdate.STATUS_CANCELLED_IN_FLIGHT,
            zipline_timestamp=data['timestamp'],
            package_number=data['packageNumber'],
            **self.carry_forward_dispatched_data(order, data['packageNumber'])
        )

        if not order.delivered_status and self.all_flights_done(order):
            order.status = EmergencyOrderStatusUpdate.STATUS_DELIVERED
            order.delivered_status = EmergencyOrderStatusUpdate.objects.filter(
                order_id=order.pk,
                status=EmergencyOrderStatusUpdate.STATUS_DELIVERED
            ).order_by('-zipline_timestamp')[0]
            order.save()
        elif not order.cancelled_status and self.all_flights_cancelled(order):
            order.status = EmergencyOrderStatusUpdate.STATUS_CANCELLED
            order.cancelled_status = cancelled_in_flight_status
            order.save()

        package = self.get_package_object(order, data['packageNumber'])
        if not package.cancelled_status:
            package.status = EmergencyOrderStatusUpdate.STATUS_CANCELLED_IN_FLIGHT
            package.cancelled_status = cancelled_in_flight_status
            package.save()

        return True, {'status': 'success'}
Exemplo n.º 6
0
    def process_status_update(self, order, data):
        dispatched_data = self.carry_forward_dispatched_data(order, data['packageNumber'])
        delivered_status = EmergencyOrderStatusUpdate.create_for_order(
            order.pk,
            EmergencyOrderStatusUpdate.STATUS_DELIVERED,
            zipline_timestamp=data['timestamp'],
            package_number=data['packageNumber'],
            **dispatched_data
        )

        update_product_quantity_json_field(order.products_delivered, dispatched_data['products'])

        if not order.delivered_status and self.all_flights_done(order):
            order.status = EmergencyOrderStatusUpdate.STATUS_DELIVERED
            order.delivered_status = delivered_status

        order.save()

        package = self.get_package_object(order, data['packageNumber'])
        if not package.delivered_status:
            package.status = EmergencyOrderStatusUpdate.STATUS_DELIVERED
            package.delivered_status = delivered_status
            package.save()

        return True, {'status': 'success'}
Exemplo n.º 7
0
    def process_status_update(self, order, data):
        dispatched_status = EmergencyOrderStatusUpdate.create_for_order(
            order.pk,
            EmergencyOrderStatusUpdate.STATUS_DISPATCHED,
            zipline_timestamp=data['timestamp'],
            package_number=data['packageNumber'],
            package_id=data['packageId'],
            vehicle_id=data['vehicleId'],
            products=data['products'],
            eta=data['eta']
        )

        if not order.dispatched_status:
            order.status = EmergencyOrderStatusUpdate.STATUS_DISPATCHED
            order.dispatched_status = dispatched_status
            order.save()

        package = self.get_package_object(order, data['packageNumber'])
        if package.status not in (
            EmergencyOrderStatusUpdate.STATUS_DELIVERED,
            EmergencyOrderStatusUpdate.STATUS_CANCELLED,
        ):
            package.status = EmergencyOrderStatusUpdate.STATUS_DISPATCHED

        if not package.dispatched_status:
            package.dispatched_status = dispatched_status
            update_product_quantity_json_field(package.products, data['products'])
            package.update_calculated_fields()

        package.save()

        return True, {'status': 'success'}
Exemplo n.º 8
0
    def process_status_update(self, order, data):
        dispatched_status = EmergencyOrderStatusUpdate.create_for_order(
            order.pk,
            EmergencyOrderStatusUpdate.STATUS_DISPATCHED,
            zipline_timestamp=data['timestamp'],
            package_number=data['packageNumber'],
            package_id=data['packageId'],
            vehicle_id=data['vehicleId'],
            products=data['products'],
            eta=data['eta']
        )

        if not order.dispatched_status:
            order.status = EmergencyOrderStatusUpdate.STATUS_DISPATCHED
            order.dispatched_status = dispatched_status
            order.save()

        package = self.get_package_object(order, data['packageNumber'])
        if package.status not in (
            EmergencyOrderStatusUpdate.STATUS_DELIVERED,
            EmergencyOrderStatusUpdate.STATUS_CANCELLED,
        ):
            package.status = EmergencyOrderStatusUpdate.STATUS_DISPATCHED

        if not package.dispatched_status:
            package.dispatched_status = dispatched_status
            update_product_quantity_json_field(package.products, data['products'])
            package.update_calculated_fields()

        package.save()

        return True, {'status': 'success'}
Exemplo n.º 9
0
    def process_status_update(self, order, data):
        cancelled_in_flight_status = EmergencyOrderStatusUpdate.create_for_order(
            order.pk,
            EmergencyOrderStatusUpdate.STATUS_CANCELLED_IN_FLIGHT,
            zipline_timestamp=data['timestamp'],
            package_number=data['packageNumber'],
            **self.carry_forward_dispatched_data(order, data['packageNumber'])
        )

        if not order.delivered_status and self.all_flights_done(order):
            order.status = EmergencyOrderStatusUpdate.STATUS_DELIVERED
            order.delivered_status = EmergencyOrderStatusUpdate.objects.filter(
                order_id=order.pk,
                status=EmergencyOrderStatusUpdate.STATUS_DELIVERED
            ).order_by('-zipline_timestamp')[0]
            order.save()
        elif not order.cancelled_status and self.all_flights_cancelled(order):
            order.status = EmergencyOrderStatusUpdate.STATUS_CANCELLED
            order.cancelled_status = cancelled_in_flight_status
            order.save()

        package = self.get_package_object(order, data['packageNumber'])
        if not package.cancelled_status:
            package.status = EmergencyOrderStatusUpdate.STATUS_CANCELLED_IN_FLIGHT
            package.cancelled_status = cancelled_in_flight_status
            package.save()

        return True, {'status': 'success'}
Exemplo n.º 10
0
def handle_request_received(order):
    """
    Handles a received response from Zipline.
    :param order: the EmergencyOrder for the request
    """
    order.received_status = EmergencyOrderStatusUpdate.create_for_order(
        order.pk, EmergencyOrderStatusUpdate.STATUS_RECEIVED)
Exemplo n.º 11
0
    def process_status_update(self, order, data):
        dispatched_data = self.carry_forward_dispatched_data(order, data['packageNumber'])
        delivered_status = EmergencyOrderStatusUpdate.create_for_order(
            order.pk,
            EmergencyOrderStatusUpdate.STATUS_DELIVERED,
            zipline_timestamp=data['timestamp'],
            package_number=data['packageNumber'],
            **dispatched_data
        )

        update_product_quantity_json_field(order.products_delivered, dispatched_data['products'])

        if not order.delivered_status and self.all_flights_done(order):
            order.status = EmergencyOrderStatusUpdate.STATUS_DELIVERED
            order.delivered_status = delivered_status

        order.save()

        package = self.get_package_object(order, data['packageNumber'])
        if not package.delivered_status:
            package.status = EmergencyOrderStatusUpdate.STATUS_DELIVERED
            package.delivered_status = delivered_status
            package.save()

        return True, {'status': 'success'}
Exemplo n.º 12
0
def handle_request_rejected(order, reason):
    """
    Handles a rejected response from Zipline.
    :param order: the EmergencyOrder for the request
    """
    order.rejected_status = EmergencyOrderStatusUpdate.create_for_order(
        order.pk,
        EmergencyOrderStatusUpdate.STATUS_REJECTED,
        additional_text=reason)
Exemplo n.º 13
0
def handle_request_received(order):
    """
    Handles a received response from Zipline.
    :param order: the EmergencyOrder for the request
    """
    order.received_status = EmergencyOrderStatusUpdate.create_for_order(
        order.pk,
        EmergencyOrderStatusUpdate.STATUS_RECEIVED
    )
Exemplo n.º 14
0
def update_order_products_confirmed(order, products):
    update_product_quantity_json_field(order.products_confirmed, products)
    confirmed_status = EmergencyOrderStatusUpdate.create_for_order(
        order.pk,
        EmergencyOrderStatusUpdate.STATUS_CONFIRMED,
        products=products)
    if not order.confirmed_status:
        order.confirmed_status = confirmed_status
    order.save()
Exemplo n.º 15
0
def handle_request_rejected(order, reason):
    """
    Handles a rejected response from Zipline.
    :param order: the EmergencyOrder for the request
    """
    order.rejected_status = EmergencyOrderStatusUpdate.create_for_order(
        order.pk,
        EmergencyOrderStatusUpdate.STATUS_REJECTED,
        additional_text=reason
    )
Exemplo n.º 16
0
def update_order_products_confirmed(order, products):
    update_product_quantity_json_field(order.products_confirmed, products)
    confirmed_status = EmergencyOrderStatusUpdate.create_for_order(
        order.pk,
        EmergencyOrderStatusUpdate.STATUS_CONFIRMED,
        products=products
    )
    if not order.confirmed_status:
        order.confirmed_status = confirmed_status
    order.save()
Exemplo n.º 17
0
    def process_status_update(self, order, data):
        cancelled_status = EmergencyOrderStatusUpdate.create_for_order(
            order.pk,
            EmergencyOrderStatusUpdate.STATUS_CANCELLED,
            zipline_timestamp=data['timestamp'])

        send_sms_response = False
        if not order.cancelled_status:
            send_sms_response = True
            order.status = EmergencyOrderStatusUpdate.STATUS_CANCELLED
            order.cancelled_status = cancelled_status
            order.save()

        return send_sms_response, {'status': 'success'}
Exemplo n.º 18
0
    def process_status_update(self, order, data):
        cancelled_status = EmergencyOrderStatusUpdate.create_for_order(
            order.pk,
            EmergencyOrderStatusUpdate.STATUS_CANCELLED,
            zipline_timestamp=data['timestamp']
        )

        send_sms_response = False
        if not order.cancelled_status:
            send_sms_response = True
            order.status = EmergencyOrderStatusUpdate.STATUS_CANCELLED
            order.cancelled_status = cancelled_status
            order.save()

        return send_sms_response, {'status': 'success'}
Exemplo n.º 19
0
    def process_status_update(self, order, data):
        approved_status = EmergencyOrderStatusUpdate.create_for_order(
            order.pk,
            EmergencyOrderStatusUpdate.STATUS_APPROVED,
            zipline_timestamp=data['timestamp'])

        send_sms_response = False
        if not order.approved_status:
            send_sms_response = True
            order.status = EmergencyOrderStatusUpdate.STATUS_APPROVED
            order.total_packages = data['totalPackages']
            order.approved_status = approved_status
            order.save()

        return send_sms_response, {'status': 'success'}
Exemplo n.º 20
0
    def process_status_update(self, order, data):
        approved_status = EmergencyOrderStatusUpdate.create_for_order(
            order.pk,
            EmergencyOrderStatusUpdate.STATUS_APPROVED,
            zipline_timestamp=data['timestamp']
        )

        send_sms_response = False
        if not order.approved_status:
            send_sms_response = True
            order.status = EmergencyOrderStatusUpdate.STATUS_APPROVED
            order.total_packages = data['totalPackages']
            order.approved_status = approved_status
            order.save()

        return send_sms_response, {'status': 'success'}
Exemplo n.º 21
0
def create_error_record(order, error_message):
    EmergencyOrderStatusUpdate.create_for_order(
        order.pk,
        EmergencyOrderStatusUpdate.STATUS_ERROR,
        additional_text=error_message
    )
Exemplo n.º 22
0
def create_error_record(order, error_message):
    EmergencyOrderStatusUpdate.create_for_order(
        order.pk,
        EmergencyOrderStatusUpdate.STATUS_ERROR,
        additional_text=error_message
    )