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

Forbid adding illegal product to basket

parent f08685d2
...@@ -209,6 +209,8 @@ class Item(models.Model): ...@@ -209,6 +209,8 @@ class Item(models.Model):
option: str = "", option: str = "",
second_option: str = "", second_option: str = "",
) -> "OrderItem": ) -> "OrderItem":
if self.hidden or self.end_date < timezone.now():
raise ValidationError("Ce produit est périmé ou a été caché par un administrateur. Ils n'a pas été ajouté au panier.")
order = Order.objects.get_current_order(user) order = Order.objects.get_current_order(user)
return self.add_to_order(order, quantity, customization, option, second_option) return self.add_to_order(order, quantity, customization, option, second_option)
......
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