diff --git a/gestaoRaul/comandas/__pycache__/htmx_views.cpython-310.pyc b/gestaoRaul/comandas/__pycache__/htmx_views.cpython-310.pyc index 72a74a0..61034de 100644 Binary files a/gestaoRaul/comandas/__pycache__/htmx_views.cpython-310.pyc and b/gestaoRaul/comandas/__pycache__/htmx_views.cpython-310.pyc differ diff --git a/gestaoRaul/comandas/__pycache__/urls.cpython-310.pyc b/gestaoRaul/comandas/__pycache__/urls.cpython-310.pyc index f654cbf..26a1836 100644 Binary files a/gestaoRaul/comandas/__pycache__/urls.cpython-310.pyc and b/gestaoRaul/comandas/__pycache__/urls.cpython-310.pyc differ diff --git a/gestaoRaul/comandas/__pycache__/views.cpython-310.pyc b/gestaoRaul/comandas/__pycache__/views.cpython-310.pyc index 44580ae..b0aeeda 100644 Binary files a/gestaoRaul/comandas/__pycache__/views.cpython-310.pyc and b/gestaoRaul/comandas/__pycache__/views.cpython-310.pyc differ diff --git a/gestaoRaul/comandas/htmx_views.py b/gestaoRaul/comandas/htmx_views.py index d946d19..1adb6be 100644 --- a/gestaoRaul/comandas/htmx_views.py +++ b/gestaoRaul/comandas/htmx_views.py @@ -4,12 +4,16 @@ from comandas.models import Comanda, ProductComanda from products.models import Product -def listProduct(request): +def listProduct(request, comanda_id): product = request.GET.get("search-product") products = Product.objects.filter(name__icontains=product) - return render(request, "htmx_components/htmx_list_products.html", {"products": products}) + return render(request, "htmx_components/htmx_list_products.html", {"products": products,'comanda_id':comanda_id}) def addProduct(request, product_id, comanda_id): product_comanda = ProductComanda(comanda_id=comanda_id, product_id=product_id) product_comanda.save() - return render(request, "htmx_components/htmx_add_product.html",) \ No newline at end of file + 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}) \ No newline at end of file diff --git a/gestaoRaul/comandas/templates/comandas.html b/gestaoRaul/comandas/templates/comandas.html index 1bfd0ef..3c71c9b 100644 --- a/gestaoRaul/comandas/templates/comandas.html +++ b/gestaoRaul/comandas/templates/comandas.html @@ -2,13 +2,14 @@ {% load static %} - - {% block 'title' %} -Comandas{% endblock %} +Comandas +{% endblock %} + {% block 'head' %} {% endblock %} + {% block 'body' %}
@@ -17,12 +18,11 @@ Comandas{% endblock %} {% for comanda in comandas %} - {% endfor %} @@ -41,11 +41,6 @@ Comandas{% endblock %} {% endfor %} - - - diff --git a/gestaoRaul/comandas/templates/viewcomanda.html b/gestaoRaul/comandas/templates/viewcomanda.html index dc9dfa9..c8da7db 100644 --- a/gestaoRaul/comandas/templates/viewcomanda.html +++ b/gestaoRaul/comandas/templates/viewcomanda.html @@ -19,7 +19,7 @@ Detalhes {{comanda.name}} {% block 'body' %} -{{comanda.name}}
@@ -27,7 +27,7 @@ Detalhes {{comanda.name}}{{comanda.dt_open}}
-| Produto | Preço | @@ -58,12 +58,13 @@ Detalhes {{comanda.name}}
|---|