mirror of
https://github.com/welton89/RRBEC.git
synced 2026-04-05 05:25:40 +00:00
feat: logout | testes permissoes | redirecionamento com base no gupo do usuario
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
{% extends "base.html" %}
|
||||
{% load static %}
|
||||
{% load custom_filter_tag %}
|
||||
|
||||
|
||||
|
||||
{% block 'title' %}
|
||||
@@ -41,12 +43,13 @@ Detalhes {{comanda.name}}
|
||||
{% endif %}
|
||||
|
||||
|
||||
<button class="button" id="imprimirFichas"
|
||||
{% if comanda.status != 'OPEN'%}
|
||||
<button class="button" id="imprimirFichas"
|
||||
style="display: none;"
|
||||
{% endif %}
|
||||
onclick="imprimirFichas()">Fichas</button>
|
||||
|
||||
{% endif %}
|
||||
|
||||
{% if user|groupUser:"Gerente" %}
|
||||
<button class="button" id="imprimirFichas" hx-get="{% url 'reopenComanda' comanda.id %} " hx-trigger="click" hx-swap="none" onclick="reloadPage()"
|
||||
{% if comanda.status == 'OPEN'%}
|
||||
style="display: none;"
|
||||
@@ -55,6 +58,8 @@ Detalhes {{comanda.name}}
|
||||
{% endif %}
|
||||
>Reabrir</button>
|
||||
|
||||
{% endif %}
|
||||
|
||||
|
||||
</div>
|
||||
<div>
|
||||
|
||||
Binary file not shown.
@@ -12,4 +12,9 @@ def filter_total(value):
|
||||
total = 0
|
||||
for produto in consumo:
|
||||
total += produto.product.price
|
||||
return f'R$ {total}'
|
||||
return f'R$ {total}'
|
||||
|
||||
|
||||
@register.filter(name='groupUser')
|
||||
def has_group(user, group_name):
|
||||
return user.groups.filter(name=group_name).exists()
|
||||
Binary file not shown.
Binary file not shown.
@@ -3,6 +3,7 @@
|
||||
|
||||
|
||||
|
||||
|
||||
{% block 'head' %}
|
||||
<link rel="stylesheet" href="{% static 'home/css/home.css' %}">
|
||||
|
||||
|
||||
@@ -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 = []
|
||||
|
||||
Binary file not shown.
@@ -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
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
{% load static %}
|
||||
{% load custom_filter_tag %}
|
||||
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
@@ -21,14 +23,15 @@
|
||||
<nav class="nav-bar">
|
||||
<div class="logo">
|
||||
<h1>
|
||||
<!-- RRBEC -->
|
||||
<img src="{% static 'midia/logo.png' %}" width="60">
|
||||
|
||||
</h1>
|
||||
</div>
|
||||
<div class="nav-list">
|
||||
<ul>
|
||||
{% if user|groupUser:"Gerente" %}
|
||||
<li class="nav-item"><a href="{% url 'home' %}" class="nav-link">Início</a></li>
|
||||
{% endif %}
|
||||
<li class="nav-item"><a href="{% url 'comandas' %}" class="nav-link">Comandas</a></li>
|
||||
<li class="nav-item"><a href="{% url 'pedidos' %}" class="nav-link">Cozinha</a></li>
|
||||
<li class="nav-item"><a href="{% url 'viewBalcao' %}" class="nav-link">Balcão</a></li>
|
||||
@@ -59,7 +62,9 @@
|
||||
</nav>
|
||||
<div class="mobile-menu">
|
||||
<ul>
|
||||
{% if user|groupUser:"Gerente" %}
|
||||
<li class="nav-item"><a href="{% url 'home' %}" class="nav-link">Início</a></li>
|
||||
{% endif %}
|
||||
<li class="nav-item"><a href="{% url 'comandas' %}" class="nav-link">Comandas</a></li>
|
||||
<li class="nav-item"><a href="{% url 'pedidos' %}" class="nav-link">Cozinha</a></li>
|
||||
<li class="nav-item"><a href="{% url 'mapMesas' %}" class="nav-link">Mapa</a></li>
|
||||
|
||||
Reference in New Issue
Block a user