fix: delete cart_offer / cart_auction rows after payment finalizes
The previous fix drained line items from a paid cart but left the cart_offer (or cart_auction) association row alive. The cart then reads as is_negotiated=True with zero products — the cart page renders the green "Offer accepted" card on top of an empty cart, the cart total shows the override amount, and the navbar reads "Cart $1.00 (0)" — 0 items, $1.00 total. _finalize_auction_offer_state now also dbsession.delete()s the association row immediately after flipping offer.state=PAID and auction.state=SETTLED. The negotiation is single-use; once the offer is PAID, the cart should be a plain empty cart. The Cart.auction_offer_override_in_cents property short-circuits on cart_auctions/cart_offers truthiness, so removing the row makes is_negotiated return False, the negotiation card disappears, and total_in_cents stops returning the override.
This commit is contained in:
parent
ef9146956d
commit
6e44027354
1 changed files with 14 additions and 2 deletions
|
|
@ -100,8 +100,18 @@ def _create_gift_card_transactions(cart, invoices, request):
|
|||
|
||||
def _finalize_auction_offer_state(cart, request):
|
||||
"""MPS-20 + MPS-21: when a cart linked to an auction or offer is paid,
|
||||
flip auction.state=SETTLED and offer.state=PAID. Called from the
|
||||
cart success path after invoices are written."""
|
||||
flip auction.state=SETTLED and offer.state=PAID, then delete the
|
||||
cart_auction / cart_offer association rows so the cart's
|
||||
is_negotiated property returns False going forward.
|
||||
|
||||
Without the association cleanup, a freshly-drained cart still
|
||||
reads as "negotiated" — its template renders the green
|
||||
"Offer accepted" card on top of an empty cart, the cart total
|
||||
shows the override amount, and `Cart $X.XX (0)` reads as a
|
||||
contradiction. The negotiation row is single-use; once the
|
||||
offer / auction is PAID / SETTLED, the cart should be a normal
|
||||
empty cart again.
|
||||
"""
|
||||
from ..models.auction import (
|
||||
AUCTION_STATE_SETTLED,
|
||||
now_timestamp as auction_now,
|
||||
|
|
@ -119,9 +129,11 @@ def _finalize_auction_offer_state(cart, request):
|
|||
auction.winning_bid_id = winning_bid.id
|
||||
auction.updated_timestamp = auction_now()
|
||||
request.dbsession.add(auction)
|
||||
request.dbsession.delete(ca)
|
||||
|
||||
for co in list(cart.cart_offers):
|
||||
offer_mark_paid(co.offer)
|
||||
request.dbsession.delete(co)
|
||||
|
||||
|
||||
def get_cart_from_matchdict(request):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue