feat: login

This commit is contained in:
2025-01-14 15:44:50 -03:00
parent 3b006e7a63
commit 9b4e1cfca4
27 changed files with 210 additions and 51 deletions

Binary file not shown.

View File

@@ -1,5 +1,7 @@
from django.utils.decorators import method_decorator from django.utils.decorators import method_decorator
from django.http import HttpResponseForbidden, HttpResponseRedirect from django.http import HttpResponseForbidden, HttpResponseRedirect
from django.shortcuts import render, redirect
def group_required(groupName): def group_required(groupName):
@@ -11,7 +13,7 @@ def group_required(groupName):
else: else:
return HttpResponseForbidden('tu nao tem acesso rapa') return HttpResponseForbidden('tu nao tem acesso rapa')
else: else:
return HttpResponseForbidden('Direcionar para tela de login aqui') return redirect('login')
return wrapper return wrapper
return decorator return decorator

View File

@@ -18,7 +18,7 @@ from django.contrib import admin
from django.urls import path, include from django.urls import path, include
urlpatterns = [ urlpatterns = [
path('admin/', admin.site.urls), path('admin/', admin.site.urls, name='admin'),
path('', include('home.urls')), path('', include('home.urls')),
path('login/', include('login.urls')), path('login/', include('login.urls')),
path('products/', include('products.urls')), path('products/', include('products.urls')),

View File

@@ -22,7 +22,7 @@ def home(request):
produtos_mais_vendidos = ProductComanda.objects.values('product').annotate( produtos_mais_vendidos = ProductComanda.objects.values('product').annotate(
quantidade=Count('product'), quantidade=Count('product'),
nome=F('product__name') ).order_by('-quantidade')[:5] nome=F('product__name') ).order_by('-quantidade')[:5]
return render(request, 'home.html', {'total_pagamentos': total_pagamentos, 'pagamentos': pagamentos, 'qdt_pagamentos': qdt_pagamentos, 'produtos_mais_vendidos': produtos_mais_vendidos, 'ticekMedio': ticekMedio}) return render(request, 'home.html', {'total_pagamentos': total_pagamentos, 'pagamentos': pagamentos, 'qdt_pagamentos': qdt_pagamentos, 'produtos_mais_vendidos': produtos_mais_vendidos, 'ticekMedio': ticekMedio, })
@group_required(groupName='Gerente') @group_required(groupName='Gerente')
def chartCuisine(request): def chartCuisine(request):

Binary file not shown.

Binary file not shown.

View File

@@ -1,13 +1,32 @@
<!DOCTYPE html> {% load static %}
<html> <html>
<head> <head>
<title>Login</title> <Title>Login Form</Title>
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="stylesheet" href="{% static 'pico.css' %}">
<link rel="stylesheet" href="{% static 'login/css/login.css' %}">
</head> </head>
<body> <body>
<form method="post"> <div class="c-form">
<h2>
<img src="{% static 'midia/logo.png' %}" width="140px">
</h2>
<div class="c-input">
<form method="post" class="c-inputBox">
{% csrf_token %} {% csrf_token %}
{{ form.as_p }} {{ form.as_p }}
<button type="submit">Entrar</button> <div class="c-inputBox">
<input type="submit" name="" value="Entrar">
</div>
</form> </form>
</div>
<!-- <p class="forgot">Forgot Password? <a href="#">Click Here</a></p> -->
</div>
</body> </body>
</html> </html>

View File

@@ -3,4 +3,5 @@ from . import views
urlpatterns = [ urlpatterns = [
path('', views.login_view, name='login'), path('', views.login_view, name='login'),
path('logout', views.logout_view, name='logout'),
] ]

View File

@@ -1,7 +1,13 @@
from django.shortcuts import render, redirect from django.shortcuts import render, redirect
from django.contrib.auth import authenticate, login from django.contrib.auth import authenticate, login, logout
from django.contrib.auth.forms import AuthenticationForm from django.contrib.auth.forms import AuthenticationForm
def logout_view(request):
logout(request)
return redirect('login')
def login_view(request): def login_view(request):
if request.method == 'POST': if request.method == 'POST':
form = AuthenticationForm(data=request.POST) form = AuthenticationForm(data=request.POST)
@@ -11,7 +17,7 @@ def login_view(request):
user = authenticate(username=username, password=password) user = authenticate(username=username, password=password)
if user is not None: if user is not None:
login(request, user) login(request, user)
return redirect('home') # Substitua 'home' pelo nome da sua URL inicial return redirect('home')
else: else:
pass pass
# Mensagem de erro: Credenciais inválidas # Mensagem de erro: Credenciais inválidas

View File

@@ -6,6 +6,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="{% static 'midia/favicon/favicon.ico' %}" />
<link rel="stylesheet" href="{% static 'pico.css' %}"> <link rel="stylesheet" href="{% static 'pico.css' %}">
<link rel="stylesheet" href="{% static 'base.css' %}"> <link rel="stylesheet" href="{% static 'base.css' %}">
@@ -19,7 +20,11 @@
<header class="p-header"> <header class="p-header">
<nav class="nav-bar"> <nav class="nav-bar">
<div class="logo"> <div class="logo">
<h1>RRBEC</h1> <h1>
<!-- RRBEC -->
<img src="{% static 'midia/logo.png' %}" width="60">
</h1>
</div> </div>
<div class="nav-list"> <div class="nav-list">
<ul> <ul>
@@ -35,14 +40,17 @@
<a href="{% url 'products' %}" class="nav-link">Produtos</a> <a href="{% url 'products' %}" class="nav-link">Produtos</a>
<a href="{% url 'products' %}" class="nav-link">Categorias</a> <a href="{% url 'products' %}" class="nav-link">Categorias</a>
<a href="{% url 'products' %}" class="nav-link">Clientes</a> <a href="{% url 'products' %}" class="nav-link">Clientes</a>
<a href="{% url 'products' %}" class="nav-link">Admin</a>
</div> </div>
</div> </div>
</ul> </ul>
</div> </div>
<div class="login-button">
<button onclick="entrar()" ><a href="#">Entrar</a></button> <div class="logout-button">
<p>{{ user.first_name }} {{ user.last_name }}</p>
<a href="{% url 'logout' %}"><img src="{% static 'midia/icons/logout.svg' %}" style="width: 40px;"></a>
</div> </div>
<div class="mobile-menu-icon"> <div class="mobile-menu-icon">
@@ -67,8 +75,9 @@
</div> </div>
</div> </div>
</ul> </ul>
<div class="login-button"> <div class="logout-button">
<button onclick="entrar()"><a href="#">Entrar</a></button> {{ user.first_name }} {{ user.last_name }}
<a href="{% url 'logout' %}"><img src="{% static 'midia/icons/logout.svg' %}" style="width: 40px;"></a>
</div> </div>
</div> </div>
</header> </header>

View File

@@ -25,18 +25,16 @@ text-align: center;
.nav-bar { .nav-bar {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
padding: 0.1rem 2rem; padding: 0.1rem 1rem;
} }
.logo { .logo {
display: flex; display: flex;
margin-top: 5px;
align-items: center; align-items: center;
} }
.logo h1 {
color: #fff;
}
.nav-list { .nav-list {
display: flex; display: flex;
@@ -45,7 +43,7 @@ text-align: center;
.nav-list ul { .nav-list ul {
display: flex; display: flex;
justify-content: center; justify-content: space-between;
list-style: none; list-style: none;
} }
@@ -60,11 +58,13 @@ text-align: center;
font-weight: 400; font-weight: 400;
} }
.login-button button { .logout-button{
display: grid;
grid-template-columns: repeat(2, 1fr);
/* justify-content: center; */
border: none; border: none;
padding: 10px 15px;
border-radius: 5px; border-radius: 5px;
margin-top: 10px; margin-top: 20px;
} }
.login-button button a { .login-button button a {
@@ -82,14 +82,7 @@ text-align: center;
display: none; display: none;
} }
/* .dropbtn {
background-color: #04AA6D;
color: white;
padding: 16px;
font-size: 16px;
border: none;
}
*/
.dropdown { .dropdown {
position: relative; position: relative;
display: inline-block; display: inline-block;
@@ -135,7 +128,7 @@ text-align: center;
.nav-item { .nav-item {
display: none; display: none;
} }
.login-button { .logout-button {
display: none; display: none;
} }
.mobile-menu-icon { .mobile-menu-icon {
@@ -156,11 +149,13 @@ text-align: center;
display: block; display: block;
padding-top: 1.2rem; padding-top: 1.2rem;
} }
.mobile-menu .login-button { .mobile-menu .logout-button {
display: block; display: block;
justify-items: center;
justify-self: center;
padding: 1rem 2rem; padding: 1rem 2rem;
} }
.mobile-menu .login-button button { .mobile-menu .logout-button button {
width: 100%; width: 100%;
} }
.open { .open {

View File

@@ -0,0 +1,99 @@
/* @import url('https://fonts.googleapis.com/css2?family=Oswald&display=swap'); */
*
{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Oswald', sans-serif;
}
body
{
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
/* background: #060c21; */
}
.c-form
{
position: relative;
background: #060c21d8;
border: 1px solid #3f3f3f;
box-shadow: 5px 5px 10px rgba(87, 86, 86, 0.788);
width: 350px;
padding: 40px 40px 60px;
border-radius: 10px;
text-align: center;
}
.c-form::before
{
content: '';
position: absolute;
top: -2px;
right: -2px;
bottom: -2px;
left: -2px;
background: linear-gradient(315deg,#591309,#fee4c1);
z-index: -1;
transform: skew(2deg,1deg);
border-radius: 10px;
}
.c-form h2
{
color: #fff;
font-weight: 500;
text-transform: uppercase;
letter-spacing: 5px;
transition: transform 0.2s;
}
.c-form h2:hover
{
scale: 1.05;
transition: transform 0.2s;
}
.c-form .c-input
{
margin-top: 40px;
text-align: left;
}
.c-form .c-input .c-inputBox
{
margin-top: 10px;
}
.c-form .c-input .c-inputBox label
{
display: block;
color: #fff;
margin-bottom: 5px;
font-size: 18px;
letter-spacing: 1px;
}
.c-form .c-input .c-inputBox input
{
position: relative;
width: 100%;
height: 40px;
border: none;
outline: none;
padding: 5px 15px;
background:linear-gradient(315deg,#591309,#fee4c1) ;
color: #fff;
font-size: 18px;
border-radius: 10px;
}
.c-form .c-input .c-inputBox input[type="submit"]
{
cursor: pointer;
margin-top: 20px;
letter-spacing: 1px;
}
.c-form .c-input .c-inputBox input[type="submit"]:hover
{
background:linear-gradient(315deg,#fee4c1,#591309) ;
}
.c-form .c-input .c-inputBox input[type="submit"]:active
{
color: rgba(255, 255, 255, 0.521);
background:linear-gradient(315deg,#fee4c1,#591309) ;
}

View File

@@ -2,8 +2,8 @@
display: grid; display: grid;
grid-template-columns: repeat(3, 2fr); grid-template-columns: repeat(3, 2fr);
gap: 20px; gap: 20px;
max-width: 800px; /* Define a largura máxima do grid */ max-width: 800px;
margin: 0 auto; /* Centraliza o grid na página */ margin: 0 auto;
} }
.card { .card {
@@ -13,7 +13,7 @@
border-radius: 15px; border-radius: 15px;
box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.2); box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.2);
text-align: center; text-align: center;
line-height: 120px; /* Centraliza o texto verticalmente */ line-height: 120px;
font-size: 20px; font-size: 20px;
font-weight: bold; font-weight: bold;
color: #333; color: #333;
@@ -26,11 +26,10 @@
border-radius: 15px; border-radius: 15px;
box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.2); box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.2);
text-align: center; text-align: center;
line-height: 50px; /* Centraliza o texto verticalmente */ line-height: 50px;
font-size: 10px; font-size: 10px;
font-weight: bold; font-weight: bold;
color: #333; color: #333;
/* position: absolute; */
transition: transform 0.2s; transition: transform 0.2s;
cursor: move; cursor: move;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 1.3 MiB

View File

@@ -0,0 +1,21 @@
{
"name": "MyWebSite",
"short_name": "MySite",
"icons": [
{
"src": "/web-app-manifest-192x192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "maskable"
},
{
"src": "/web-app-manifest-512x512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "maskable"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 KiB

View File

@@ -0,0 +1,7 @@
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Transformed by: SVG Repo Mixer Tools -->
<svg width="118px" height="118px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<g id="SVGRepo_bgCarrier" stroke-width="0"/>

After

Width:  |  Height:  |  Size: 1.4 KiB