diff --git a/gestaoRaul/comandas/__pycache__/htmx_views.cpython-310.pyc b/gestaoRaul/comandas/__pycache__/htmx_views.cpython-310.pyc new file mode 100644 index 0000000..72a74a0 Binary files /dev/null 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 9fa1582..f654cbf 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 6fe7555..44580ae 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 new file mode 100644 index 0000000..d946d19 --- /dev/null +++ b/gestaoRaul/comandas/htmx_views.py @@ -0,0 +1,15 @@ +from django.shortcuts import render, redirect + +from comandas.models import Comanda, ProductComanda +from products.models import Product + + +def listProduct(request): + product = request.GET.get("search-product") + products = Product.objects.filter(name__icontains=product) + return render(request, "htmx_components/htmx_list_products.html", {"products": products}) + +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 diff --git a/gestaoRaul/comandas/templates/viewcomanda.html b/gestaoRaul/comandas/templates/viewcomanda.html index f4fed07..dc9dfa9 100644 --- a/gestaoRaul/comandas/templates/viewcomanda.html +++ b/gestaoRaul/comandas/templates/viewcomanda.html @@ -58,8 +58,15 @@ Detalhes {{comanda.name}}