def mark_as_shipped(self, order_id: int): """ Mark the order as shipped - cannot be done unless the shipping info has been assigned :param order_id: The id of the order to update """ order = Order.get_by_id(order_id) if order.shipment is None: raise Exception("Cannot mark as shipped without shipment info") order.status = OrderStatus.Shipped.value order.save()
def _simple_status_change(self, order_id, status: OrderStatus) -> Order: """ A helper method to change the state :param order_id: The order to modify :param status: The new status :return: The order model """ order = Order.get_by_id(order_id) order.status = status.value order.save() return order