Keep marketplace purchase history when a seller is deleted

Taken offers now survive seller deletion (seller SET_NULL) so buyers keep
their history; open and withdrawn offers are still removed with the seller.
Update documented test counts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Mikei386andClaude Opus 5.5 committed 2026-11-21 12:38:41 +01:00
1 parent b272581606
commit e45b020700
5 files changed
+56 -5

No files matched your search

+14
View File
@@ -214,5 +214,19 @@ class MarketplaceTests(CatalogTestCase):
def test_deleting_seller_removes_offers_and_reservations(self):
self.offer()
withdrawn = self.offer()
withdraw_marketplace_offer(self.alice, withdrawn.pk)
self.alice.delete()
self.assertFalse(MarketplaceOffer.objects.exists())
def test_deleting_seller_keeps_buyer_purchase_history(self):
offer = self.offer(quantity=1)
take_marketplace_offer(self.bob, offer.pk)
self.alice.delete()
offer.refresh_from_db()
self.assertIsNone(offer.seller_id)
self.assertEqual(offer.buyer, self.bob)
self.assertEqual(offer.status, MarketplaceOffer.Status.TAKEN)
self.client.force_login(self.bob)
response = self.client.get(reverse("marketplace"))
self.assertContains(response, "Übernommen")