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

@@ -9,6 +9,7 @@ from mesas.models import Mesa
from products.models import Product
from payments.models import Payments
from typePay.models import TypePay
from gestaoRaul.decorators import group_required
def listProductBalcao(request, comanda_id, search_product):
comanda_id = request.GET.get("id-comanda-balcao")
@@ -32,7 +33,7 @@ def listProductBalcao(request, comanda_id, search_product):
return render(request, "htmx_components/htmx_list_products_balcao.html", {"products": products,'comanda_id':comanda_id})
@group_required(groupName='Garçom')
def addProductBalcao(request, product_id, comanda_id, qtd):
for i in range(qtd):
product_comanda = ProductComanda(comanda_id=comanda_id, product_id=product_id)
@@ -43,6 +44,7 @@ def addProductBalcao(request, product_id, comanda_id, qtd):
total += produto.product.price
return render(request, "htmx_components/htmx_list_products_in_balcao.html",{'consumo': consumo, 'total': total})
@group_required(groupName='Garçom')
@csrf_exempt
def addProductBalcaoTeclado(request, product_id, comanda_id, qtd):
for i in range(qtd):
@@ -54,7 +56,7 @@ def addProductBalcaoTeclado(request, product_id, comanda_id, qtd):
total += produto.product.price
return render(request, "htmx_components/htmx_list_products_in_balcao.html",{'consumo': consumo, 'total': total})
@group_required(groupName='Garçom')
def removeProductBalcao(request, productComanda_id):
product_comanda = ProductComanda.objects.get(id=productComanda_id)
consumo = ProductComanda.objects.filter(comanda=product_comanda.comanda)
@@ -64,7 +66,7 @@ def removeProductBalcao(request, productComanda_id):
total += produto.product.price
return render(request, "htmx_components/htmx_list_products_in_balcao.html",{'consumo': consumo, 'total': total})
@group_required(groupName='Garçom')
def paymentBalcao(request, comanda_id):
typePayment = TypePay.objects.get(id=1)
consumo = ProductComanda.objects.filter(comanda=comanda_id)

View File

@@ -5,10 +5,11 @@ from products.models import Product
from mesas.models import Mesa
from django.db.models import Count, F
from django.contrib.auth.models import User
from gestaoRaul.decorators import group_required
@group_required(groupName='Garçom')
def viewBalcao(request):
try:
comanda = Comanda.objects.get(name='VENDA BALCÃO')

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])

Binary file not shown.

View File

@@ -4,6 +4,7 @@ from django.shortcuts import render
from orders.models import Order
from django.db.models import Q
from gestaoRaul.decorators import group_required
def viewsOrders(request):
@@ -11,6 +12,7 @@ def viewsOrders(request):
orders = Order.objects.filter(queue__gte=fifteen_hours_ago )
return render(request, 'orders.html',{'orders': orders})
@group_required(groupName='Cozinha')
def preparing(request, order_id):
order = Order.objects.get(id=order_id)
order.preparing = timezone.now()
@@ -20,6 +22,7 @@ def preparing(request, order_id):
return render(request, 'htmx_components/orders/htmx_list_orders.html',{'orders': orders})
@group_required(groupName='Cozinha')
def finished(request, order_id):
order = Order.objects.get(id=order_id)
order.finished = timezone.now()
@@ -28,6 +31,7 @@ def finished(request, order_id):
orders = Order.objects.filter(queue__gte=fifteen_hours_ago )
return render(request, 'htmx_components/orders/htmx_list_orders.html',{'orders': orders})
@group_required(groupName='Garçom')
def delivered(request, order_id):
order = Order.objects.get(id=order_id)
order.delivered = timezone.now()

View File

@@ -2,19 +2,24 @@ from django.shortcuts import render, redirect
from categories.models import Categories
from products.models import Product
from gestaoRaul.decorators import group_required
@group_required(groupName='Garçom')
def products(request):
protucts = Product.objects.all()
categories = Categories.objects.all()
return render(request, 'products.html', {'products': protucts, 'categories': categories})
@group_required(groupName='Garçom')
def searchProduct(request):
product = request.GET.get("search-product")
products = Product.objects.filter(name__icontains=product)
return render(request, "htmx_components/products/htmx_search_products.html", {"products": products})
@group_required(groupName='Gerente')
def createProduct(request):
name = request.POST.get('name')
description = request.POST.get('description')
@@ -25,6 +30,8 @@ def createProduct(request):
return redirect('/products')
@group_required(groupName='Gerente')
def onOffProduct(request):
id = request.POST.get('id-product')
product_id = int(id)
@@ -35,6 +42,7 @@ def onOffProduct(request):
return render(request, "htmx_components/products/htmx_search_products.html", {"products": products})
@group_required(groupName='Gerente')
def editProduct(request, productId):
product_id = int(request.POST.get('productId'))
# product_id = productId