add status functionality

This commit is contained in:
2025-05-26 10:33:09 +03:00
parent 4897a5050d
commit 50e6da10f1
7 changed files with 92 additions and 49 deletions

View File

@@ -0,0 +1,23 @@
# Generated by Django 5.2.1 on 2025-05-26 07:11
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('routes', '0006_alter_city_id_alter_country_id_alter_leads_id_and_more'),
]
operations = [
migrations.AddField(
model_name='route',
name='created_at',
field=models.DateTimeField(auto_now_add=True, null=True),
),
migrations.AddField(
model_name='route',
name='status',
field=models.CharField(choices=[('actual', 'Актуально'), ('canceled', 'Отменено'), ('completed', 'Завершено')], default='actual', max_length=20),
),
]

View File

@@ -105,6 +105,17 @@ class Route(models.Model):
blank=True, null=True
)
status = models.CharField(
max_length=20,
choices=[
("actual", "Актуально"),
("canceled", "Отменено"),
("completed", "Завершено"),
],
default="actual",
)
created_at = models.DateTimeField(auto_now_add=True, null=True, blank=True)
def __str__(self) -> str:
from_city_name = self.from_city.name if self.from_city else 'Не указан'
to_city_name = self.to_city.name if self.to_city else 'Не указан'