diff --git a/gestaoRaul/comandas/__pycache__/htmx_views.cpython-310.pyc b/gestaoRaul/comandas/__pycache__/htmx_views.cpython-310.pyc index 897b583..4eac452 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 0cdca79..abe55cc 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/htmx_views.py b/gestaoRaul/comandas/htmx_views.py index fd935b2..3fc9d57 100644 --- a/gestaoRaul/comandas/htmx_views.py +++ b/gestaoRaul/comandas/htmx_views.py @@ -1,3 +1,4 @@ +from django.http import JsonResponse from django.shortcuts import render, redirect from comandas.models import Comanda, ProductComanda @@ -17,11 +18,13 @@ def listProduct(request, comanda_id): return render(request, "htmx_components/htmx_list_products.html", {"products": products,'comanda_id':comanda_id}) def addProduct(request, product_id, comanda_id): + obs = request.GET.get("obs") product_comanda = ProductComanda(comanda_id=comanda_id, product_id=product_id) product_comanda.save() product = Product.objects.get(id=product_id) comanda = Comanda.objects.get(id=comanda_id) print(product.cuisine) + if product.cuisine == True: order = Order(id_comanda=comanda, id_product=product, productComanda=product_comanda, obs='') order.save() @@ -31,6 +34,13 @@ def addProduct(request, product_id, comanda_id): total += produto.product.price return render(request, "htmx_components/htmx_list_products_in_comanda.html",{'consumo': consumo, 'total': total}) +def editOrders(request, productComanda_id, obs): + order = Order.objects.get(productComanda=productComanda_id) + print(obs) + order.obs = obs + order.save() + return JsonResponse({'status': 'ok'}) + def removeProductComanda(request, productComanda_id): product_comanda = ProductComanda.objects.get(id=productComanda_id) diff --git a/gestaoRaul/comandas/templates/viewcomanda.html b/gestaoRaul/comandas/templates/viewcomanda.html index afc3acb..8e37126 100644 --- a/gestaoRaul/comandas/templates/viewcomanda.html +++ b/gestaoRaul/comandas/templates/viewcomanda.html @@ -17,6 +17,7 @@ Detalhes {{comanda.name}} {% block 'body' %}
+