color changes, client, realization time

This commit is contained in:
2025-01-04 14:57:53 +01:00
parent 948dbbca61
commit c3f306575f
15 changed files with 247 additions and 144 deletions

View File

@ -0,0 +1,36 @@
# Generated by Django 5.1.4 on 2024-12-21 13:34
import app.models
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('app', '0002_meal'),
]
operations = [
migrations.AlterModelOptions(
name='meal',
options={'verbose_name': 'Danie', 'verbose_name_plural': 'Dania'},
),
migrations.AlterModelOptions(
name='order',
options={'verbose_name': 'Zamówienie', 'verbose_name_plural': 'Zamówienia'},
),
migrations.AlterModelOptions(
name='waiter',
options={'verbose_name': 'Kelner', 'verbose_name_plural': 'Kelnerzy'},
),
migrations.AddField(
model_name='order',
name='client',
field=models.CharField(blank=True, max_length=250, null=True, verbose_name='Klient'),
),
migrations.AddField(
model_name='order',
name='realization_time',
field=models.DateTimeField(default=app.models.default_realization_time, verbose_name='Godzina realizacji'),
),
]

View File

@ -0,0 +1,23 @@
# Generated by Django 5.1.4 on 2024-12-21 14:25
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('app', '0003_alter_meal_options_alter_order_options_and_more'),
]
operations = [
migrations.AlterField(
model_name='order',
name='realization_time',
field=models.CharField(blank=True, max_length=250, null=True, verbose_name='Godzina realizacji'),
),
migrations.AlterField(
model_name='order',
name='status',
field=models.PositiveSmallIntegerField(choices=[(1, 'Zamówienie złożone'), (2, 'Zamówienie w trakcie przygotowywania'), (3, 'Zamówienie gotowe'), (4, 'Zamówienie zrealizowane')], default=1, verbose_name='Status zamówienia'),
),
]

View File

@ -1,9 +1,14 @@
from django.db import models
from django.utils.translation import gettext_lazy as _
from django.utils import timezone
# Create your models here.
def default_realization_time():
return timezone.now() # + datetime.timedelta(hours=1)
class Waiter(models.Model):
name = models.CharField(_('Imię i nazwisko'), max_length=120)
@ -11,8 +16,8 @@ class Waiter(models.Model):
return self.name
class Meta:
verbose_name = _("Kelner")
verbose_name_plural = _("Kelnerzy")
verbose_name = _('Kelner')
verbose_name_plural = _('Kelnerzy')
class Meal(models.Model):
@ -22,23 +27,31 @@ class Meal(models.Model):
return self.name
class Meta:
verbose_name = _("Danie")
verbose_name_plural = _("Dania")
verbose_name = _('Danie')
verbose_name_plural = _('Dania')
class Order(models.Model):
created_on = models.DateTimeField(_('Utworzono'), auto_now_add=True)
updated_on = models.DateTimeField(_('Zaktualizowano'), auto_now=True)
waiter = models.ForeignKey(
Waiter, models.SET_NULL, related_name='orders', verbose_name=_('Kelner'), null=True
realization_time = models.CharField(
_('Godzina realizacji'), max_length=250, null=True, blank=True
)
waiter = models.ForeignKey(
Waiter,
models.SET_NULL,
related_name='orders',
verbose_name=_('Kelner'),
null=True,
)
client = models.CharField(_('Klient'), max_length=250, null=True, blank=True)
data = models.JSONField(_('Dane zamówienia'), default=dict)
class StatusChoices(models.IntegerChoices):
ORDERED = (1, _('Zamówienie złożone'))
IN_PROGRESS = (2, ('Zamówienie w trakcie przygotowywania'))
READY = (3, _('Zamówienie gotowe'))
FINALIZED = (4, _('Zamówienie skończone'))
FINALIZED = (4, _('Zamówienie zrealizowane'))
status = models.PositiveSmallIntegerField(
_('Status zamówienia'),
@ -47,8 +60,8 @@ class Order(models.Model):
)
def __str__(self):
return self.id
return str(self.id)
class Meta:
verbose_name = _("Zamówienie")
verbose_name_plural = _("Zamówienia")
verbose_name = _('Zamówienie')
verbose_name_plural = _('Zamówienia')

View File

@ -67,6 +67,8 @@ class OrderSerializer(serializers.ModelSerializer):
'id',
'created_on',
'updated_on',
'realization_time',
'client',
'waiter',
'waiter_name',
'data',