mirror of
https://github.com/welton89/RRBEC.git
synced 2026-04-05 13:35:42 +00:00
create views comandas
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -1,12 +1,33 @@
|
||||
{% extends "base.html" %}
|
||||
{% load static %}
|
||||
|
||||
|
||||
|
||||
|
||||
{% block 'title' %}
|
||||
Type Pay
|
||||
Comandas{% endblock %}
|
||||
{% block 'head' %}
|
||||
<link rel="stylesheet" href="{% static 'comandas/css/comandas.css' %}">
|
||||
{% endblock %}
|
||||
|
||||
{% 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 %}
|
||||
29
gestaoRaul/comandas/templates/viewcomanda.html
Normal file
29
gestaoRaul/comandas/templates/viewcomanda.html
Normal 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 %}
|
||||
@@ -4,6 +4,7 @@ from . import views
|
||||
|
||||
urlpatterns = [
|
||||
path('', views.comandas, name='comandas'),
|
||||
path('viewcomanda/', views.viewComanda, name='viewcomanda'),
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,19 @@
|
||||
from django.shortcuts import render
|
||||
from django.shortcuts import render, redirect
|
||||
|
||||
from comandas.models import Comanda
|
||||
|
||||
# Create your views here.
|
||||
|
||||
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -9,5 +9,8 @@ class Mesa(models.Model):
|
||||
location = models.CharField(max_length=255, null=True, blank=True)
|
||||
active = models.BooleanField(default=False)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
# Foreign Key to Comandas model (assuming it exists)
|
||||
# comanda = models.ForeignKey('Comandas', on_delete=models.DO_NOTHING, db_column='id_mesa')
|
||||
@@ -18,7 +18,21 @@ RRB&C - 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 %}
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ from . import views
|
||||
|
||||
urlpatterns = [
|
||||
path('', views.mesas, name='mesas'),
|
||||
path('onOffmesa/', views.onOffmesa, name='onOffmesa'),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from django.shortcuts import render
|
||||
from django.shortcuts import render,redirect
|
||||
|
||||
from mesas.models import Mesa
|
||||
|
||||
@@ -6,4 +6,14 @@ from mesas.models import Mesa
|
||||
|
||||
def mesas(request):
|
||||
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')
|
||||
Binary file not shown.
@@ -22,7 +22,7 @@
|
||||
<ul>
|
||||
<li><a href="#">Home</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="#">Categorias</a></li>
|
||||
<li><a href="#">Sobre</a></li>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
26
gestaoRaul/templates/static/comandas/css/viewcomanda.css
Normal file
26
gestaoRaul/templates/static/comandas/css/viewcomanda.css
Normal 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);
|
||||
}
|
||||
Binary file not shown.
@@ -3,4 +3,7 @@ from django.db import models
|
||||
# Create your models here.
|
||||
class TypePay(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
name = models.CharField(max_length=255)
|
||||
name = models.CharField(max_length=255)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
Reference in New Issue
Block a user