Minor admin improvements and remove unique_together deprecated Meta

Also make rolling stock unique per consist
This commit is contained in:
2025-01-08 23:28:04 +01:00
parent f286ec9780
commit 26be22c0bd
11 changed files with 169 additions and 15 deletions

View File

@@ -0,0 +1,23 @@
# Generated by Django 5.1.4 on 2025-01-08 22:22
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("roster", "0030_rollingstock_price"),
]
operations = [
migrations.AlterUniqueTogether(
name="rollingstockdocument",
unique_together=set(),
),
migrations.AddConstraint(
model_name="rollingstockdocument",
constraint=models.UniqueConstraint(
fields=("rolling_stock", "file"), name="unique_stock_file"
),
),
]

View File

@@ -156,8 +156,13 @@ class RollingStockDocument(Document):
RollingStock, on_delete=models.CASCADE, related_name="document"
)
class Meta(object):
unique_together = ("rolling_stock", "file")
class Meta:
constraints = [
models.UniqueConstraint(
fields=["rolling_stock", "file"],
name="unique_stock_file"
)
]
def rolling_stock_image_upload(instance, filename):