add product in comanda

This commit is contained in:
2024-12-13 10:48:18 -03:00
parent a3bb7bb674
commit b74d817730
12 changed files with 61 additions and 11 deletions

View File

@@ -1,9 +1,9 @@
from django.shortcuts import render, redirect
from comandas.models import Comanda, ProductComanda
from products.models import Product
from mesas.models import Mesa
# Create your views here.
def comandas(request):
comandas = Comanda.objects.all()
@@ -12,26 +12,19 @@ def comandas(request):
def viewComanda(request):
id = request.GET.get('parametro')
comanda_id = int(id)
comanda = Comanda.objects.get(id=comanda_id)
consumo = ProductComanda.objects.filter(comanda=comanda_id)
products = Product.objects.all()
total = 0
for produto in consumo:
total += produto.product.price
return render(request, 'viewcomanda.html', {'comanda': comanda, 'consumo': consumo, 'total': total})
return render(request, 'viewcomanda.html', {'comanda': comanda, 'consumo': consumo, 'total': total, 'products': products})
def addProduct(request):
pass
# id = request.GET.get('parametro')
# comanda_id = int(id)
# comanda = Comanda.objects.get(id=comanda_id)
# return render(request, 'addproduct.html', {'comanda': comanda})
def createComanda(request):
name = request.POST.get('name-comanda')