mirror of
https://github.com/welton89/RRBEC.git
synced 2026-04-05 05:25:40 +00:00
criado metodo de mais vendidos no comandas.models | limitar lista de products a 15 itens
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -16,23 +16,13 @@ from gestaoRaul.decorators import group_required
|
||||
def listProductBalcao(request, comanda_id, search_product):
|
||||
comanda_id = request.GET.get("id-comanda-balcao")
|
||||
if search_product == '*':
|
||||
produtos_mais_vendidos = list(ProductComanda.objects.values('product').annotate(
|
||||
quantidade=Count('product'),
|
||||
nome=F('product__name') ).order_by('-quantidade'))
|
||||
products = Product.objects.all()
|
||||
products_ordenados = []
|
||||
|
||||
for produto in produtos_mais_vendidos:
|
||||
for p in products:
|
||||
if p.active == True and p.name == produto['nome']:
|
||||
products_ordenados.append(p)
|
||||
|
||||
products_ordenados = ProductComanda.maisVendidos()
|
||||
|
||||
return render(request, "htmx_components/htmx_list_products_balcao.html", {"products": products_ordenados,'comanda_id':comanda_id})
|
||||
else:
|
||||
product = search_product
|
||||
products = Product.objects.filter(name__icontains=product, active=True)
|
||||
return render(request, "htmx_components/htmx_list_products_balcao.html", {"products": products,'comanda_id':comanda_id})
|
||||
return render(request, "htmx_components/htmx_list_products_balcao.html", {"products": products[:15],'comanda_id':comanda_id})
|
||||
|
||||
|
||||
@group_required(groupName='Garçom')
|
||||
|
||||
@@ -20,17 +20,7 @@ def viewBalcao(request):
|
||||
comanda.save()
|
||||
|
||||
consumo = ProductComanda.objects.filter(comanda=comanda.id)
|
||||
produtos_mais_vendidos = list(ProductComanda.objects.values('product').annotate(
|
||||
quantidade=Count('product'),
|
||||
nome=F('product__name') ).order_by('-quantidade'))
|
||||
products = Product.objects.all()
|
||||
products_ordenados = []
|
||||
|
||||
for produto in produtos_mais_vendidos:
|
||||
for p in products:
|
||||
if p.name == produto['nome'] and p.active == True:
|
||||
products_ordenados.append(p)
|
||||
|
||||
products_ordenados = ProductComanda.maisVendidos()
|
||||
total = 0
|
||||
for produto in consumo:
|
||||
total += produto.product.price
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,6 @@
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
from django.db.models import Count, F
|
||||
|
||||
|
||||
|
||||
@@ -7,7 +8,6 @@ from clients.models import Client
|
||||
from products.models import Product
|
||||
from mesas.models import Mesa
|
||||
from typePay.models import TypePay
|
||||
# from payments.models import Payments
|
||||
|
||||
class Comanda(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
@@ -32,3 +32,15 @@ class ProductComanda(models.Model):
|
||||
return self.comanda.name + " - " + self.product.name
|
||||
|
||||
|
||||
def maisVendidos():
|
||||
produtos_mais_vendidos = list(ProductComanda.objects.values('product').annotate(
|
||||
quantidade=Count('product'),
|
||||
nome=F('product__name') ).order_by('-quantidade'))
|
||||
|
||||
products = Product.objects.all()
|
||||
products_ordenados = []
|
||||
for produto in produtos_mais_vendidos:
|
||||
for p in products:
|
||||
if p.name == produto['nome'] and p.active == True:
|
||||
products_ordenados.append(p)
|
||||
return products_ordenados[:15]
|
||||
@@ -32,24 +32,12 @@ def viewComanda(request):
|
||||
comanda_id = int(id)
|
||||
comanda = Comanda.objects.get(id=comanda_id)
|
||||
consumo = ProductComanda.objects.filter(comanda=comanda_id)
|
||||
# consumo[0].product.
|
||||
parcial = Payments.objects.filter(comanda=comanda_id)
|
||||
mesas = Mesa.objects.all()
|
||||
clients = Client.objects.filter(active=True)
|
||||
|
||||
produtos_mais_vendidos = list(ProductComanda.objects.values('product').annotate(
|
||||
quantidade=Count('product'),
|
||||
nome=F('product__name') ).order_by('-quantidade'))
|
||||
|
||||
products = Product.objects.all()
|
||||
products_ordenados = []
|
||||
for produto in produtos_mais_vendidos:
|
||||
for p in products:
|
||||
if p.name == produto['nome'] and p.active == True:
|
||||
products_ordenados.append(p)
|
||||
products_ordenados = ProductComanda.maisVendidos()
|
||||
valores = somar(consumo,comanda)
|
||||
|
||||
return render(request, 'viewcomanda.html', {'config':config, 'valores':valores,'parcials':parcial,'clients':clients,'comanda': comanda, 'consumo': consumo, 'products': products_ordenados,'mesas':mesas})
|
||||
return render(request, 'viewcomanda.html', {'config':config, 'valores':valores,'parcials':parcial,'clients':clients,'comanda': comanda, 'consumo': consumo, 'products': products_ordenados[:15],'mesas':mesas})
|
||||
|
||||
|
||||
@group_required(groupName='Garçom')
|
||||
@@ -202,9 +190,12 @@ def addProduct(request, product_id, comanda_id):
|
||||
|
||||
|
||||
def listProduct(request, comanda_id, product):
|
||||
if product == '*':
|
||||
allProducts = ProductComanda.maisVendidos()
|
||||
else:
|
||||
allProducts = Product.objects.filter(name__icontains=product)
|
||||
products = []
|
||||
for p in allProducts:
|
||||
if p.active == True:
|
||||
products.append(p)
|
||||
return render(request, "htmx_components/comandas/htmx_list_products.html", {"products": products,'comanda_id':comanda_id})
|
||||
return render(request, "htmx_components/comandas/htmx_list_products.html", {"products": products[:15],'comanda_id':comanda_id})
|
||||
Binary file not shown.
Binary file not shown.
@@ -2,6 +2,7 @@ from django.db import models
|
||||
|
||||
from categories.models import Categories
|
||||
|
||||
|
||||
# Create your models here.
|
||||
class Product(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
|
||||
@@ -19,6 +19,7 @@ Produtos
|
||||
<button class="btn-primary"
|
||||
onclick="openModal()" id="openModal">Novo Produto</button>
|
||||
<input type="text" id="search-product" name="search-product" placeholder="Buscar Produto" hx-get="{% url 'searchProduct' %}" hx-trigger="keyup" hx-target="#product-list">
|
||||
<a href="https://raulrockbar.blogspot.com/p/cardapio.html" target="_blank">Cardápio Digital</a>
|
||||
</div>
|
||||
|
||||
<table id="product-list">
|
||||
|
||||
@@ -154,8 +154,8 @@ input, textarea, select {
|
||||
align-content: center;
|
||||
text-align: center;
|
||||
line-height: 1.5;
|
||||
background: var(--main-gradient);
|
||||
box-shadow: 3px 3px 10px rgba(2, 2, 2, 0.678);
|
||||
/* background: var(--main-gradient); */
|
||||
/* box-shadow: 3px 3px 10px rgba(2, 2, 2, 0.678); */
|
||||
border-radius: 5px;
|
||||
transition: transform 0.4s, box-shadow 0.4s;
|
||||
background-size: cover;
|
||||
@@ -168,9 +168,9 @@ input, textarea, select {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 150px;
|
||||
height: 130px;
|
||||
background-color: rgba(0, 0, 0, 0.737);
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.595);
|
||||
}
|
||||
|
||||
.card-product-p {
|
||||
@@ -186,6 +186,14 @@ input, textarea, select {
|
||||
box-shadow: 0px 0px 10px rgba(86, 187, 255, 0.815);
|
||||
}
|
||||
|
||||
|
||||
@media screen and (max-width: 1028px) {
|
||||
.card-product {
|
||||
background-size: cover !important;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.p-header {
|
||||
background-color: #24252a;
|
||||
box-shadow: 0px 3px 10px #464646;
|
||||
|
||||
@@ -31,9 +31,9 @@
|
||||
}
|
||||
|
||||
.modal-product{
|
||||
/* position: relative; */
|
||||
position: relative;
|
||||
width: 100%;
|
||||
/* height: 400px; */
|
||||
/* height: 750; */
|
||||
background-image: url('https://placehold.co/600x800/efc7b8/49291c?text=Sem_Imagem'); /* URL da imagem */
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
|
||||
Reference in New Issue
Block a user