lint code

This commit is contained in:
Laetitia Getti 2023-05-16 17:01:22 +02:00
parent 90e23ed016
commit 53a7d04597
4 changed files with 16 additions and 14 deletions

View file

@ -71,11 +71,11 @@ class OrderAuthor(models.Model):
last_name = models.CharField(verbose_name="Nom")
phone = models.CharField(
verbose_name="Numéro de téléphone",
help_text="Pour vous que l'organisateur·ice vous contacte en cas de besoin",
help_text="Pour que l'organisateur·ice vous contacte en cas de besoin",
)
email = models.CharField(
verbose_name="Adresse mail",
help_text="Pour vous que l'organisateur·ice vous contacte en cas de besoin",
help_text="Pour que l'organisateur·ice vous contacte en cas de besoin",
)
def __str__(self): # pragma: no cover

View file

@ -132,7 +132,9 @@ def order(request, grouped_order_id):
"""Creates an AnonymousUser, and an Order for this GroupedOrder, with related OrderedItems"""
grouped_order = get_object_or_404(GroupedOrder, pk=grouped_order_id)
# get a dict with (quantity_{{item_id}}:{{quantity}})
orders_dict = {k: v for k, v in request.POST.items() if k.startswith("quantity")}
orders_dict = {
key: value for key, value in request.POST.items() if key.startswith("quantity")
}
first_name = request.POST["first_name"]
last_name = request.POST["last_name"]
phone = request.POST["phone"]
@ -141,12 +143,12 @@ def order(request, grouped_order_id):
first_name=first_name, last_name=last_name, email=email, phone=phone
)
order = Order.objects.create(author=author, grouped_order=grouped_order)
for k, v in orders_dict.items():
if v == "":
v = 0
if int(v) > 0:
item = grouped_order.item_set.get(pk=k.split("_")[1])
OrderedItem.objects.create(nb=v, order=order, item=item)
for key, quantity in orders_dict.items():
if quantity == "":
quantity = 0
if int(quantity) > 0:
item = grouped_order.item_set.get(pk=key.split("_")[1])
OrderedItem.objects.create(nb=quantity, order=order, item=item)
compute_ordered_nb(item)
compute_order_articles_nb(order)
if order.articles_nb == 0: