mirror of
https://github.com/welton89/RRBEC.git
synced 2026-04-05 13:35:42 +00:00
feat: alteração no db
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,25 @@
|
||||
# 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'),
|
||||
),
|
||||
]
|
||||
Binary file not shown.
@@ -5,7 +5,6 @@ from products.models import Product
|
||||
from mesas.models import Mesa
|
||||
from typePay.models import TypePay
|
||||
|
||||
# Create your models here.
|
||||
class Comanda(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
mesa = models.ForeignKey(Mesa, on_delete=models.CASCADE)
|
||||
@@ -14,6 +13,7 @@ class Comanda(models.Model):
|
||||
dt_close = models.DateTimeField(null=True, blank=True)
|
||||
client = models.ForeignKey(Client, on_delete=models.SET_NULL, null=True, blank=True)
|
||||
name = models.CharField(max_length=255)
|
||||
status = models.CharField(max_length=255, default="OPEN")
|
||||
def __str__(self) -> str:
|
||||
return self.name
|
||||
|
||||
@@ -21,7 +21,7 @@ class ProductComanda(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
comanda = models.ForeignKey(Comanda, on_delete=models.CASCADE)
|
||||
data_time = models.DateTimeField(auto_now_add=True)
|
||||
product = models.ForeignKey(Product, on_delete=models.CASCADE)
|
||||
product = models.ForeignKey(Product, on_delete=models.PROTECT)
|
||||
applicant = models.CharField(max_length=255, null=True, blank=True)
|
||||
def __str__(self) -> str:
|
||||
return self.comanda.name + " - " + self.product.name
|
||||
@@ -6,7 +6,7 @@ from mesas.models import Mesa
|
||||
|
||||
|
||||
def comandas(request):
|
||||
comandas = Comanda.objects.all()
|
||||
comandas = Comanda.objects.filter(status__in=["OPEN", "PAYING"])
|
||||
mesas = Mesa.objects.all()
|
||||
return render(request, 'comandas.html', {'comandas': comandas, 'mesas': mesas})
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,23 @@
|
||||
# Generated by Django 5.1.4 on 2024-12-20 12:36
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('products', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='product',
|
||||
name='image',
|
||||
field=models.ImageField(blank=True, null=True, upload_to=''),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='product',
|
||||
name='quantity',
|
||||
field=models.IntegerField(default=0),
|
||||
),
|
||||
]
|
||||
Binary file not shown.
@@ -7,7 +7,9 @@ class Product(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
name = models.CharField(max_length=100)
|
||||
description = models.TextField(null=True, blank=True)
|
||||
image = models.ImageField(null=True, blank=True)
|
||||
price = models.DecimalField(max_digits=10, decimal_places=2)
|
||||
quantity = models.IntegerField(null=False, default=0)
|
||||
category = models.ForeignKey(Categories, on_delete=models.CASCADE)
|
||||
active = models.BooleanField(default=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user