feat: first filter custom | valor total da comanda no card

This commit is contained in:
2025-01-08 14:39:52 -03:00
parent 1b5b02be0d
commit a41960dcd5
13 changed files with 32 additions and 15 deletions

View File

@@ -1,5 +1,6 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load static %} {% load static %}
{% load custom_filter_tag %}
{% block 'title' %} {% block 'title' %}
@@ -14,6 +15,7 @@ Comandas
<body> <body>
<button id="openModal">Abrir Comanda</button> <button id="openModal">Abrir Comanda</button>
<div class="grid-container "> <div class="grid-container ">
{% for comanda in comandas %} {% for comanda in comandas %}
@@ -21,17 +23,22 @@ Comandas
<a href="{% url 'viewcomanda' %}?parametro={{ comanda.id }}" style="text-decoration: none;"> <a href="{% url 'viewcomanda' %}?parametro={{ comanda.id }}" style="text-decoration: none;">
<header <header
{% if comanda.status == 'OPEN' %} {% if comanda.status == 'OPEN' %}
style="min-height: 60px;border-radius: 10px 10px 0px 0px; background-color: #036800;" style="padding: 5px; min-height: 60px;border-radius: 5px 5px 0px 0px; background-color: #036800;"
{% elif comanda.status == 'PAYING' %} {% elif comanda.status == 'PAYING' %}
style="min-height: 60px;border-radius: 10px 10px 0px 0px; background-color: rgb(165, 86, 33);" style="padding: 5px; min-height: 60px;border-radius: 5px 5px 0px 0px; background-color: rgb(165, 86, 33);"
{% endif %} {% endif %}
> >
{{comanda.name}} | {{comanda.mesa}} <p>{{comanda.name}}</p>
<p>{{comanda.mesa}}</p>
</header> </header>
<br> <div style="padding: 5px;">
<p> <p>
Aberta ás: {{comanda.dt_open|date:"H:i"}} Hora: {{comanda.dt_open|date:"H:i"}}
</p> </p>
<p>
{{ comanda.id | total }}
</p>
</div>
</a> </a>
</div> </div>
{% endfor %} {% endfor %}

View File

@@ -0,0 +1,15 @@
from django import template
from comandas.models import Comanda, ProductComanda
register = template.Library()
@register.filter(name='total')
def filter_total(value):
id = value
comanda_id = int(id)
consumo = ProductComanda.objects.filter(comanda=comanda_id)
total = 0
for produto in consumo:
total += produto.product.price
return f'R$ {total}'

View File

@@ -47,3 +47,5 @@ def createComanda(request):
return redirect('comandas') return redirect('comandas')

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

File diff suppressed because one or more lines are too long

View File

@@ -10,13 +10,14 @@
.card-comanda { .card-comanda {
width: 80%; width: 80%;
/* gap: 5px; */
/* min-width: 220px; /* min-width: 220px;
min-height: 250px; */ min-height: 250px; */
background-color: #292929; background-color: #292929;
border-radius: 10px 10px 5px 5px; border-radius: 5px;
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: 30px; line-height: 15px;
font-size: 15px; font-size: 15px;
font-weight: bold; font-weight: bold;
color: #333; color: #333;

File diff suppressed because one or more lines are too long