diff --git a/gestaoRaul/comandas/templates/viewcomanda.html b/gestaoRaul/comandas/templates/viewcomanda.html index e9f84d5..eaa8d1f 100644 --- a/gestaoRaul/comandas/templates/viewcomanda.html +++ b/gestaoRaul/comandas/templates/viewcomanda.html @@ -1,5 +1,7 @@ {% extends "base.html" %} {% load static %} +{% load custom_filter_tag %} + {% block 'title' %} @@ -41,12 +43,13 @@ Detalhes {{comanda.name}} {% endif %} - - + {% endif %} + + {% if user|groupUser:"Gerente" %} + {% endif %} +
diff --git a/gestaoRaul/comandas/templatetags/__pycache__/custom_filter_tag.cpython-313.pyc b/gestaoRaul/comandas/templatetags/__pycache__/custom_filter_tag.cpython-313.pyc index 4ff35c5..45dcd70 100644 Binary files a/gestaoRaul/comandas/templatetags/__pycache__/custom_filter_tag.cpython-313.pyc and b/gestaoRaul/comandas/templatetags/__pycache__/custom_filter_tag.cpython-313.pyc differ diff --git a/gestaoRaul/comandas/templatetags/custom_filter_tag.py b/gestaoRaul/comandas/templatetags/custom_filter_tag.py index 69fbd94..ca70cca 100644 --- a/gestaoRaul/comandas/templatetags/custom_filter_tag.py +++ b/gestaoRaul/comandas/templatetags/custom_filter_tag.py @@ -12,4 +12,9 @@ def filter_total(value): total = 0 for produto in consumo: total += produto.product.price - return f'R$ {total}' \ No newline at end of file + return f'R$ {total}' + + +@register.filter(name='groupUser') +def has_group(user, group_name): + return user.groups.filter(name=group_name).exists() \ No newline at end of file diff --git a/gestaoRaul/db.sqlite3 b/gestaoRaul/db.sqlite3 index cf62d00..439c161 100644 Binary files a/gestaoRaul/db.sqlite3 and b/gestaoRaul/db.sqlite3 differ diff --git a/gestaoRaul/home/__pycache__/views.cpython-313.pyc b/gestaoRaul/home/__pycache__/views.cpython-313.pyc index 8b5aceb..bb859bb 100644 Binary files a/gestaoRaul/home/__pycache__/views.cpython-313.pyc and b/gestaoRaul/home/__pycache__/views.cpython-313.pyc differ diff --git a/gestaoRaul/home/templates/home.html b/gestaoRaul/home/templates/home.html index ac6f9cb..8f9ab30 100644 --- a/gestaoRaul/home/templates/home.html +++ b/gestaoRaul/home/templates/home.html @@ -3,6 +3,7 @@ + {% block 'head' %} diff --git a/gestaoRaul/home/views.py b/gestaoRaul/home/views.py index 594c90a..c47f3f1 100644 --- a/gestaoRaul/home/views.py +++ b/gestaoRaul/home/views.py @@ -26,7 +26,7 @@ def home(request): @group_required(groupName='Gerente') def chartCuisine(request): - print(request.user.id) + print(request.user.groups.all()) print(request.user.is_authenticated) # fulano = User() tFila = [] diff --git a/gestaoRaul/login/__pycache__/views.cpython-313.pyc b/gestaoRaul/login/__pycache__/views.cpython-313.pyc index 711f878..57bc2bd 100644 Binary files a/gestaoRaul/login/__pycache__/views.cpython-313.pyc and b/gestaoRaul/login/__pycache__/views.cpython-313.pyc differ diff --git a/gestaoRaul/login/views.py b/gestaoRaul/login/views.py index aee3e67..6b6289d 100644 --- a/gestaoRaul/login/views.py +++ b/gestaoRaul/login/views.py @@ -1,11 +1,12 @@ from django.shortcuts import render, redirect from django.contrib.auth import authenticate, login, logout + from django.contrib.auth.forms import AuthenticationForm def logout_view(request): logout(request) - return redirect('login') + return redirect('login') def login_view(request): @@ -17,7 +18,10 @@ def login_view(request): user = authenticate(username=username, password=password) if user is not None: login(request, user) - return redirect('home') + if request.user.groups.filter(name='Admin').exists() or request.user.groups.filter(name='Gerente').exists() : + return redirect('home') + else: + return redirect('comandas') else: pass # Mensagem de erro: Credenciais inválidas diff --git a/gestaoRaul/templates/base.html b/gestaoRaul/templates/base.html index d8a904c..ed6e18f 100644 --- a/gestaoRaul/templates/base.html +++ b/gestaoRaul/templates/base.html @@ -1,4 +1,6 @@ {% load static %} +{% load custom_filter_tag %} + @@ -21,14 +23,15 @@