Commit e6de7612 authored by HEVELINE Thomas's avatar HEVELINE Thomas Committed by HEVELINE Thomas

(44): fix indentation

parent a07e10ec
......@@ -72,9 +72,9 @@ class Item(models.Model):
@property
def customizable(self) -> bool:
return (
(self.customization is True)
or (self.option != "")
or (self.second_option != "")
(self.customization is True)
or (self.option != "")
or (self.second_option != "")
)
@property
......@@ -269,44 +269,39 @@ class Order(models.Model):
except Payment.DoesNotExist:
return 'None'
@property
def contains_cotiz(self) -> bool:
return any(i.item.is_cotiz for i in self.items.all())
@property
def contains_cotiz(self) -> bool:
return any(i.item.is_cotiz for i in self.items.all())
def compute_price(self) -> None:
self.price = Decimal("0.00")
for item in self.items.all():
if not item.is_pack_item:
self.price += item.get_final_price()
def post_payment(self) -> None:
for orderitem in self.items.all():
orderitem.post_payment()
def compute_price(self) -> None:
self.price = Decimal("0.00")
for item in self.items.all():
if not item.is_pack_item:
self.price += item.get_final_price()
def save(self, *args, **kwargs) -> None:
if self.ordered and self.ordered_date is None:
self.ordered_date = timezone.now()
def post_payment(self) -> None:
for orderitem in self.items.all():
orderitem.post_payment()
elif self.rejected and self.rejected_date is None:
self.rejected_date = timezone.now()
def save(self, *args, **kwargs) -> None:
if self.ordered and self.ordered_date is None:
self.ordered_date = timezone.now()
super().save(*args, **kwargs)
elif self.rejected and self.rejected_date is None:
self.rejected_date = timezone.now()
super().save(*args, **kwargs)
def clean_illegal_items(self) -> int:
# No suppression if already ordered
if self.ordered:
return 0
deleted_count = 0
for orderitem in self.items.filter(pack_parent=None):
if orderitem.item.contains_illegal_items:
orderitem.delete()
deleted_count += 1
return deleted_count
def clean_illegal_items(self) -> int:
# No suppression if already ordered
if self.ordered:
return 0
deleted_count = 0
for orderitem in self.items.filter(pack_parent=None):
if orderitem.item.contains_illegal_items:
orderitem.delete()
deleted_count += 1
return deleted_count
class Payment(models.Model):
......@@ -327,10 +322,10 @@ class OrderItemManager(models.Manager):
def get_ordered_quantity(self, item: "Item", user) -> int:
"""Get the total quantity ever ordered/in order by that user"""
return (
self.filter(item=item, order__user=user, order__rejected=False).aggregate(
quantity=Sum("quantity")
)["quantity"]
or 0
self.filter(item=item, order__user=user, order__rejected=False).aggregate(
quantity=Sum("quantity")
)["quantity"]
or 0
)
......
......@@ -26,9 +26,9 @@ SECRET_KEY = "&d3ykoj75pkdv_q^4%ens@047+qi^_^379rg#!o%zg1j=pmwi&"
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
INTERNAL_IPS = ["192.168.0.181"]
INTERNAL_IPS = []
ALLOWED_HOSTS: List[str] = ["192.168.0.181"]
ALLOWED_HOSTS: List[str] = ['127.0.0.1']
# Application definition
......
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