mirror of
https://github.com/welton89/RRBEC.git
synced 2026-04-05 13:35:42 +00:00
add permissoes as views
This commit is contained in:
Binary file not shown.
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user