Commit 3ed2dc11 authored by MOREAU Ulysse's avatar MOREAU Ulysse

Correct tests for illegal pack with legal items

parent c49ea900
......@@ -286,18 +286,11 @@ class Order(models.Model):
super().save(*args, **kwargs)
def clean_illegal_items(self) -> int:
self.refresh_from_db()
# No suppression if already ordered
if self.ordered:
return 0
deleted_count = 0
for orderitem in self.items.all():
print(orderitem, orderitem.item.name)
print(orderitem.pack_parent)
orderitem.refresh_from_db()
if orderitem.pack_parent:
# It is allowed to have an illegal item in a pack
continue
for orderitem in self.items.filter(pack_parent=None):
if orderitem.item.contains_illegal_items:
orderitem.delete()
deleted_count += 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment