API: Fix crash with deletion of cart positions with add-ons

This commit is contained in:
Raphael Michel
2022-10-25 12:08:58 +02:00
parent b99d21df69
commit 4983073172
2 changed files with 11 additions and 0 deletions

View File

@@ -92,6 +92,11 @@ class CartPositionViewSet(CreateModelMixin, DestroyModelMixin, viewsets.ReadOnly
def perform_create(self, serializer):
raise NotImplementedError()
@transaction.atomic()
def perform_destroy(self, instance):
instance.addons.all().delete()
instance.delete()
def _require_locking(self, quota_diff, voucher_use_diff, seat_diff):
if voucher_use_diff or seat_diff:
# If any vouchers or seats are used, we lock to make sure we don't redeem them to often