create views comandas

This commit is contained in:
2024-12-12 10:47:36 -03:00
parent ae5d47fa7c
commit 2f84ca97c3
20 changed files with 158 additions and 10 deletions

View File

@@ -1,12 +1,33 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load static %}
{% block 'title' %} {% block 'title' %}
Type Pay Comandas{% endblock %}
{% block 'head' %}
<link rel="stylesheet" href="{% static 'comandas/css/comandas.css' %}">
{% endblock %} {% endblock %}
{% block 'body' %} {% block 'body' %}
Body Type Pay
body>
<div class="grid-container">
{% for comanda in comandas %}
<div href="{% url 'viewcomanda' %}?parametro={{ comanda.id }}" class="card"> <a href="{% url 'viewcomanda' %}?parametro={{ comanda.id }}">{{comanda.name}} </a>
</div>
{% endfor %}
</div>
</body>
{% endblock %} {% endblock %}

View File

@@ -0,0 +1,29 @@
{% extends "base.html" %}
{% load static %}
{% block 'title' %}
Comandas{% endblock %}
{% block 'head' %}
<link rel="stylesheet" href="{% static 'comandas/css/viewcomanda.css' %}">
{% endblock %}
{% block 'body' %}
body>
<div class="grid-container">
<h4>{{comanda.id}}</h4>
<h4>{{comanda.name}}</h4>
<h4>{{comanda.mesa}}</h4>
<h4>{{comanda.dt_open}}</h4>
</div>
</body>
{% endblock %}

View File

@@ -4,6 +4,7 @@ from . import views
urlpatterns = [ urlpatterns = [
path('', views.comandas, name='comandas'), path('', views.comandas, name='comandas'),
path('viewcomanda/', views.viewComanda, name='viewcomanda'),

View File

@@ -1,6 +1,19 @@
from django.shortcuts import render from django.shortcuts import render, redirect
from comandas.models import Comanda
# Create your views here. # Create your views here.
def comandas(request): def comandas(request):
return render(request, 'comandas.html') comandas = Comanda.objects.all()
return render(request, 'comandas.html', {'comandas': comandas})
def viewComanda(request):
id = request.GET.get('parametro')
comanda_id = int(id)
comanda = Comanda.objects.get(id=comanda_id)
return render(request, 'viewcomanda.html', {'comanda': comanda})

Binary file not shown.

View File

@@ -9,5 +9,8 @@ class Mesa(models.Model):
location = models.CharField(max_length=255, null=True, blank=True) location = models.CharField(max_length=255, null=True, blank=True)
active = models.BooleanField(default=False) active = models.BooleanField(default=False)
def __str__(self):
return self.name
# Foreign Key to Comandas model (assuming it exists) # Foreign Key to Comandas model (assuming it exists)
# comanda = models.ForeignKey('Comandas', on_delete=models.DO_NOTHING, db_column='id_mesa') # comanda = models.ForeignKey('Comandas', on_delete=models.DO_NOTHING, db_column='id_mesa')

View File

@@ -18,7 +18,21 @@ RRB&C - Mesas
{% for mesa in mesas %} {% for mesa in mesas %}
<div class="card">{{mesa.name}}</div> <div class="card"
{% if mesa.active == True %}
style="background-color: indianred;"
{% endif %}
>{{mesa.name}}
<form action="{% url 'onOffmesa' %}" method="post">
{% csrf_token %}
<input type="hidden" name="id-mesa" value="{{ mesa.id }}">
<button type="submit">On/Off</button>
</form>
</div>
{% endfor %} {% endfor %}

View File

@@ -4,6 +4,8 @@ from . import views
urlpatterns = [ urlpatterns = [
path('', views.mesas, name='mesas'), path('', views.mesas, name='mesas'),
path('onOffmesa/', views.onOffmesa, name='onOffmesa'),

View File

@@ -1,4 +1,4 @@
from django.shortcuts import render from django.shortcuts import render,redirect
from mesas.models import Mesa from mesas.models import Mesa
@@ -6,4 +6,14 @@ from mesas.models import Mesa
def mesas(request): def mesas(request):
mesas = Mesa.objects.all() mesas = Mesa.objects.all()
return render(request, 'mesas.html', {'mesas': mesas}) return render(request, 'mesas.html', {'mesas': mesas})
def onOffmesa(request):
id = request.POST.get('id-mesa')
mesa_id = int(id)
mesa = Mesa.objects.get(id=mesa_id)
mesa.active = not mesa.active
mesa.save()
return redirect('mesas')

View File

@@ -22,7 +22,7 @@
<ul> <ul>
<li><a href="#">Home</a></li> <li><a href="#">Home</a></li>
<li><a href="{% url 'mesas' %}">Mesas</a></li> <li><a href="{% url 'mesas' %}">Mesas</a></li>
<li><a href="#">Comandas</a></li> <li><a href="{% url 'comandas' %}">Comandas</a></li>
<li><a href="{% url 'products' %}">Produtos</a></li> <li><a href="{% url 'products' %}">Produtos</a></li>
<li><a href="#">Categorias</a></li> <li><a href="#">Categorias</a></li>
<li><a href="#">Sobre</a></li> <li><a href="#">Sobre</a></li>

View File

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

View File

@@ -0,0 +1,26 @@
.grid-container {
display: grid;
grid-template-columns: repeat(1, 2fr);
gap: 20px;
max-width: 800px; /* Define a largura máxima do grid */
margin: 0 auto; /* Centraliza o grid na página */
}
.card {
width: 120px;
height: 120px;
background-color: #f2f2f2;
border-radius: 15px;
box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.2);
text-align: center;
line-height: 120px; /* Centraliza o texto verticalmente */
font-size: 20px;
font-weight: bold;
color: #333;
transition: transform 0.2s;
}
.card:hover {
transform: scale(1.05);
box-shadow: 10px 10px 20px rgba(0, 0, 0, 0.3);
}

View File

@@ -3,4 +3,7 @@ from django.db import models
# Create your models here. # Create your models here.
class TypePay(models.Model): class TypePay(models.Model):
id = models.AutoField(primary_key=True) id = models.AutoField(primary_key=True)
name = models.CharField(max_length=255) name = models.CharField(max_length=255)
def __str__(self):
return self.name