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'}
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'}
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()
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()
def setUpClass(cls): super(ReceiptTest, cls).setUpClass() EMG_AND_REC_SMS_HANDLERS.set('ils-test-domain', True, namespace=NAMESPACE_DOMAIN) cls.order = EmergencyOrder( domain=TEST_DOMAIN, requesting_user_id=cls.user1.get_id, requesting_phone_number='5551234', location=cls.user1.sql_location, location_code=cls.user1.sql_location.site_code, timestamp=datetime.utcnow() ) update_product_quantity_json_field( cls.order.products_requested, [ProductQuantity('dp', 100), ProductQuantity('fs', 50)] ) cls.order.save()
def initiate_emergency_order(domain, user, phone_number, location, products): """ :param domain: the domain in which the order is being requested :param user: the user who is initiating the emergency order request :param phone_number: the phone_number (string) of the user who is initiating the emergency order request :param location: the SQLLocation where the products should be delivered :param products: a list of ProductQuantity objects representing the products to be ordered """ from custom.zipline.tasks import send_emergency_order_request order = EmergencyOrder(domain=domain, requesting_user_id=user.get_id, requesting_phone_number=phone_number, location=location, location_code=location.site_code, timestamp=datetime.utcnow()) update_product_quantity_json_field(order.products_requested, products) order.save() send_emergency_order_request(order.pk)
def initiate_emergency_order(domain, user, phone_number, location, products): """ :param domain: the domain in which the order is being requested :param user: the user who is initiating the emergency order request :param phone_number: the phone_number (string) of the user who is initiating the emergency order request :param location: the SQLLocation where the products should be delivered :param products: a list of ProductQuantity objects representing the products to be ordered """ from custom.zipline.tasks import send_emergency_order_request order = EmergencyOrder( domain=domain, requesting_user_id=user.get_id, requesting_phone_number=phone_number, location=location, location_code=location.site_code, timestamp=datetime.utcnow() ) update_product_quantity_json_field(order.products_requested, products) order.save() send_emergency_order_request(order.pk)