add permissoes as views

This commit is contained in:
2025-01-15 13:58:45 -03:00
parent 8a13a8806a
commit 2ceae1c0e9
13 changed files with 30 additions and 5 deletions

View File

@@ -6,6 +6,7 @@ from orders.models import Order
from products.models import Product
from payments.models import Payments
from typePay.models import TypePay
from gestaoRaul.decorators import group_required
def listProduct(request, comanda_id):
@@ -17,6 +18,7 @@ def listProduct(request, comanda_id):
products.append(p)
return render(request, "htmx_components/htmx_list_products.html", {"products": products,'comanda_id':comanda_id})
@group_required(groupName='Garçom')
def addProduct(request, product_id, comanda_id):
obs = request.GET.get("obs")
product_comanda = ProductComanda(comanda_id=comanda_id, product_id=product_id)
@@ -34,6 +36,7 @@ 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})
@group_required(groupName='Garçom')
def editOrders(request, productComanda_id, obs):
order = Order.objects.get(productComanda=productComanda_id)
print(obs)
@@ -42,6 +45,7 @@ def editOrders(request, productComanda_id, obs):
return JsonResponse({'status': 'ok'})
@group_required(groupName='Garçom')
def removeProductComanda(request, productComanda_id):
product_comanda = ProductComanda.objects.get(id=productComanda_id)
consumo = ProductComanda.objects.filter(comanda=product_comanda.comanda)
@@ -51,12 +55,14 @@ def removeProductComanda(request, productComanda_id):
total += produto.product.price
return render(request, "htmx_components/htmx_list_products_in_comanda.html",{'consumo': consumo, 'total': total})
@group_required(groupName='Garçom')
def closeComanda(request, comanda_id):
comanda = Comanda.objects.get(id=comanda_id)
comanda.status = "PAYING"
comanda.save()
@group_required(groupName='Gerente')
def reopenComanda(request, comanda_id):
comanda = Comanda.objects.get(id=comanda_id)
if comanda.status == 'CLOSED':
@@ -65,6 +71,7 @@ def reopenComanda(request, comanda_id):
comanda.status = "OPEN"
comanda.save()
@group_required(groupName='Gerente')
def paymentComanda(request, comanda_id):
typePayment = TypePay.objects.get(id=1)
consumo = ProductComanda.objects.filter(comanda=comanda_id)

View File

@@ -4,14 +4,17 @@ from django.db.models import Count, F
from comandas.models import Comanda, ProductComanda
from products.models import Product
from mesas.models import Mesa
from gestaoRaul.decorators import group_required
@group_required(groupName='Garçom')
def comandas(request):
comandas = Comanda.objects.filter(status__in=["OPEN", "PAYING"])
mesas = Mesa.objects.all()
return render(request, 'comandas.html', {'comandas': comandas, 'mesas': mesas})
@group_required(groupName='Garçom')
def viewComanda(request):
id = request.GET.get('parametro')
comanda_id = int(id)
@@ -35,7 +38,7 @@ def viewComanda(request):
return render(request, 'viewcomanda.html', {'comanda': comanda, 'consumo': consumo, 'total': total, 'products': products_ordenados})
@group_required(groupName='Garçom')
def createComanda(request):
name = request.POST.get('name-comanda')
mesa_id = int(request.POST.get('select-mesa')[0])