~homeworkprod/byceps

fb66b66049d0567181a9f1007855f4e9cd7b913a — Jochen Kupperschmidt 5 months ago 9d03914
Introduce `get_order`
M byceps/services/shop/order/email/service.py => byceps/services/shop/order/email/service.py +1 -1
@@ 139,7 139,7 @@ def _assemble_email_for_paid_order_to_orderer(data: OrderEmailData) -> Message:

def _get_order_email_data(order_id: OrderID) -> OrderEmailData:
    """Collect data required for an order e-mail template."""
    order = order_service.find_order(order_id)
    order = order_service.get_order(order_id)

    shop = shop_service.get_shop(order.shop_id)
    orderer_id = order.placed_by_id

M byceps/services/shop/order/service.py => byceps/services/shop/order/service.py +11 -1
@@ 385,7 385,7 @@ def _update_payment_state(

def delete_order(order_id: OrderID) -> None:
    """Delete an order."""
    order = find_order(order_id)
    order = get_order(order_id)

    db.session.query(DbOrderEvent) \
        .filter_by(order_id=order_id) \


@@ 447,6 447,16 @@ def find_order(order_id: OrderID) -> Optional[Order]:
    return order.to_transfer_object()


def get_order(order_id: OrderID) -> Order:
    """Return the order with that id, or raise an exception."""
    order = find_order(order_id)

    if order is None:
        raise ValueError(f'Unknown order ID "{order_id}"')

    return order


def find_order_with_details(order_id: OrderID) -> Optional[Order]:
    """Return the order with that id, or `None` if not found."""
    order = DbOrder.query \

M tests/integration/services/shop/order/test_service_mark_order_as_paid.py => tests/integration/services/shop/order/test_service_mark_order_as_paid.py +1 -1
@@ 38,7 38,7 @@ def test_mark_order_as_paid(order, admin_user):
        order.id, PaymentMethod.cash, admin_user.id
    )

    order_after = order_service.find_order(order.id)
    order_after = order_service.get_order(order.id)
    assert order_after.payment_method == PaymentMethod.cash
    assert order_after.payment_state == PaymentState.paid
    assert not order_after.is_open