Commit b75f8877 authored by MOREAU Ulysse's avatar MOREAU Ulysse
Browse files

Allow illegal item in legal pack

parent 5578cd8b
......@@ -112,6 +112,24 @@ class Item(models.Model):
return True
return False
@property
def is_available_atm(self) -> bool:
return (not self.hidden) and self.end_date > timezone.now()
@property
def contains_illegal_items(self) -> bool:
# I'm commenting this out, beacause it could be useful to
# put illegal items in a legal pack. It could get chaged
# in a future update
# if self.is_pack:
# for child in self.children.all():
# if child.contains_illegal_items:
# return True
if not self.is_available_atm:
return True
return False
def no_action(self, orderitem: "OrderItem") -> None:
pass
......@@ -273,7 +291,10 @@ class Order(models.Model):
return 0
deleted_count = 0
for orderitem in self.items.all():
if not orderitem.is_available_atm:
if orderitem.pack_parent:
# It is allowed to have an illegal item in a pack
continue
if orderitem.item.contains_illegal_items:
orderitem.delete()
deleted_count += 1
return deleted_count
......@@ -352,10 +373,6 @@ class OrderItem(models.Model):
def margin_deepness(self):
return self.pack_deepness * 50 + 10
@property
def is_available_atm(self) -> bool:
return (not self.item.hidden) or self.item.end_date > timezone.now()
def get_price(self) -> Decimal:
return self.quantity * self.item.price
......
Supports Markdown
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