add botão (funcionando) remover produto da comanda

This commit is contained in:
2024-12-17 11:03:24 -03:00
parent 1e0e4d7b6f
commit 09b4f50a1b
10 changed files with 63 additions and 8 deletions

View File

@@ -14,6 +14,16 @@ def addProduct(request, product_id, comanda_id):
product_comanda.save()
consumo = ProductComanda.objects.filter(comanda=comanda_id)
total = 0
for produto in consumo:
total += produto.product.price
return render(request, "htmx_components/htmx_list_products_in_comanda.html",{'consumo': consumo, 'total': total})
def removeProductComanda(request, productComanda_id):
product_comanda = ProductComanda.objects.get(id=productComanda_id)
consumo = ProductComanda.objects.filter(comanda=product_comanda.comanda)
product_comanda.delete()
total = 0
for produto in consumo:
total += produto.product.price
return render(request, "htmx_components/htmx_list_products_in_comanda.html",{'consumo': consumo, 'total': total})