feat: create app orders and makemigrations

This commit is contained in:
2025-01-10 14:01:14 -03:00
parent faaf0d3576
commit 0e096207a6
49 changed files with 116 additions and 103 deletions

View File

@@ -1,30 +0,0 @@
# Generated by Django 5.1.4 on 2024-12-10 01:19
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
('clients', '0001_initial'),
('mesas', '0001_initial'),
('typePay', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Comanda',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('dt_open', models.DateTimeField(auto_now_add=True)),
('dt_close', models.DateTimeField(blank=True, null=True)),
('name', models.CharField(max_length=255)),
('client', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='clients.client')),
('mesa', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='mesas.mesa')),
('type_pay', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='typePay.typepay')),
],
),
]

View File

@@ -1,25 +0,0 @@
# Generated by Django 5.1.4 on 2024-12-10 01:20
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('comandas', '0001_initial'),
('products', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='ProductComanda',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('data_time', models.DateTimeField(auto_now_add=True)),
('applicant', models.CharField(blank=True, max_length=255, null=True)),
('comanda', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='comandas.comanda')),
('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='products.product')),
],
),
]

View File

@@ -1,25 +0,0 @@
# Generated by Django 5.1.4 on 2024-12-20 12:36
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('comandas', '0002_productcomanda'),
('products', '0002_product_image_product_quantity'),
]
operations = [
migrations.AddField(
model_name='comanda',
name='status',
field=models.CharField(default='OPEN', max_length=255),
),
migrations.AlterField(
model_name='productcomanda',
name='product',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='products.product'),
),
]

View File

@@ -1,3 +1,6 @@
from django.contrib import admin
# Register your models here.
from categories.models import Categories
admin.site.register(Categories)

View File

@@ -1,3 +1,6 @@
from django.contrib import admin
# Register your models here.
from clients.models import Client
admin.site.register(Client)

View File

@@ -1,3 +1,7 @@
from django.contrib import admin
# Register your models here.
from comandas.models import Comanda, ProductComanda
admin.site.register(Comanda)
admin.site.register(ProductComanda)

Binary file not shown.

View File

@@ -53,6 +53,7 @@ INSTALLED_APPS = [
'home',
'payments',
'balcao',
'orders',
]
MIDDLEWARE = [

View File

@@ -1,19 +1,7 @@
from django.contrib import admin
from categories.models import Categories
from clients.models import Client
from comandas.models import Comanda, ProductComanda
from typePay.models import TypePay
from products.models import Product
from mesas.models import Mesa
admin.site.register(Mesa)
admin.site.register(Product)
admin.site.register(Categories)
admin.site.register(Client)
admin.site.register(Comanda)
admin.site.register(TypePay)
admin.site.register(ProductComanda)
# Register your models here.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,6 @@
from django.contrib import admin
from orders.models import Order
admin.site.register(Order)

View File

@@ -0,0 +1,6 @@
from django.apps import AppConfig
class OrdersConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'orders'

View File

@@ -0,0 +1,31 @@
# Generated by Django 5.1.4 on 2025-01-10 16:28
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
('comandas', '0003_comanda_status_alter_productcomanda_product'),
('products', '0003_product_cuisine'),
]
operations = [
migrations.CreateModel(
name='Order',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('obs', models.TextField(blank=True, null=True)),
('queue', models.DateTimeField(auto_now_add=True)),
('preparing', models.DateTimeField(blank=True, null=True)),
('finished', models.DateTimeField(blank=True, null=True)),
('delivered', models.DateTimeField(blank=True, null=True)),
('canceled', models.DateTimeField(blank=True, null=True)),
('id_comanda', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='comandas.comanda')),
('id_product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='products.product')),
],
),
]

View File

View File

@@ -0,0 +1,18 @@
from django.db import models
from products.models import Product
from comandas.models import Comanda
class Order(models.Model):
id_product = models.ForeignKey(Product, on_delete=models.CASCADE)
id_comanda = models.ForeignKey(Comanda, on_delete=models.CASCADE)
obs = models.TextField(blank=True, null=True)
queue = models.DateTimeField(auto_now_add=True)
preparing = models.DateTimeField(null=True, blank=True)
finished = models.DateTimeField(null=True, blank=True)
delivered = models.DateTimeField(null=True, blank=True)
canceled = models.DateTimeField(null=True, blank=True)
def __str__(self):
return f"Pedido {self.id} - Produto: {self.id_product} - Comanda: {self.id_comanda.name}"

View File

@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

View File

@@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.

View File

@@ -1,3 +1,6 @@
from django.contrib import admin
# Register your models here.
from payments.models import Payments
admin.site.register(Payments)

View File

@@ -15,4 +15,4 @@ class Payments(models.Model):
def __str__(self):
return self.value
return self.comanda.name

View File

@@ -1,3 +1,6 @@
from django.contrib import admin
# Register your models here.
from products.models import Product
admin.site.register(Product)

View File

@@ -0,0 +1,18 @@
# Generated by Django 5.1.4 on 2025-01-10 16:24
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('products', '0002_product_image_product_quantity'),
]
operations = [
migrations.AddField(
model_name='product',
name='cuisine',
field=models.BooleanField(default=False),
),
]

View File

@@ -11,6 +11,7 @@ class Product(models.Model):
price = models.DecimalField(max_digits=10, decimal_places=2)
quantity = models.IntegerField(null=False, default=0)
category = models.ForeignKey(Categories, on_delete=models.CASCADE)
cuisine = models.BooleanField(default=False)
active = models.BooleanField(default=True)
def __str__(self) -> str:

View File

@@ -4,8 +4,8 @@
<tr>
<th style="text-align: left;">Produto</th>
<th style="text-align: left;width: 20%;">Preço</th>
<th style="text-align: left;">Quantidade</th>
<th style="text-align: left;">Categoria</th>
<th class="hide-on-mobile" style="text-align: left;">Quantidade</th>
<th class="hide-on-mobile" style="text-align: left;">Categoria</th>
<th style="text-align: left;width: 20%;">Ações</th>
</tr>
@@ -14,8 +14,8 @@
<tr>
<td id="name-{{product.id}}" >{{product.name}}</td>
<td id="price-{{product.id}}" >R$ {{product.price}}</td>
<td id="quantity-{{product.id}}" >{{product.quantity}}</td>
<td id="category-{{product.id}}" >{{product.category.name}}</td>
<td class="hide-on-mobile" id="quantity-{{product.id}}" >{{product.quantity}}</td>
<td class="hide-on-mobile" id="category-{{product.id}}" >{{product.category.name}}</td>
<td>
<div class="grid-buttons">
<img

View File

@@ -1,3 +1,5 @@
from django.contrib import admin
# Register your models here.
from typePay.models import TypePay
admin.site.register(TypePay)