mirror of
https://github.com/daniviga/django-ram.git
synced 2025-08-04 13:17:50 +02:00
Minor admin improvements and remove unique_together deprecated Meta
Also make rolling stock unique per consist
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
# Generated by Django 5.1.4 on 2025-01-08 22:25
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("metadata", "0019_alter_scale_gauge"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterUniqueTogether(
|
||||
name="decoderdocument",
|
||||
unique_together=set(),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name="rollingstocktype",
|
||||
unique_together=set(),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name="decoderdocument",
|
||||
constraint=models.UniqueConstraint(
|
||||
fields=("decoder", "file"), name="unique_decoder_file"
|
||||
),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name="rollingstocktype",
|
||||
constraint=models.UniqueConstraint(
|
||||
fields=("category", "type"), name="unique_category_type"
|
||||
),
|
||||
),
|
||||
]
|
@@ -117,7 +117,7 @@ class Decoder(models.Model):
|
||||
blank=True,
|
||||
)
|
||||
|
||||
class Meta(object):
|
||||
class Meta:
|
||||
ordering = ["manufacturer__name", "name"]
|
||||
|
||||
def __str__(self):
|
||||
@@ -135,7 +135,12 @@ class DecoderDocument(Document):
|
||||
)
|
||||
|
||||
class Meta:
|
||||
unique_together = ("decoder", "file")
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=["decoder", "file"],
|
||||
name="unique_decoder_file"
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
def calculate_ratio(ratio):
|
||||
@@ -189,8 +194,13 @@ class RollingStockType(models.Model):
|
||||
)
|
||||
slug = models.CharField(max_length=128, unique=True, editable=False)
|
||||
|
||||
class Meta(object):
|
||||
unique_together = ("category", "type")
|
||||
class Meta:
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=["category", "type"],
|
||||
name="unique_category_type"
|
||||
)
|
||||
]
|
||||
ordering = ["order"]
|
||||
|
||||
def get_absolute_url(self):
|
||||
@@ -210,7 +220,7 @@ class Tag(models.Model):
|
||||
name = models.CharField(max_length=128, unique=True)
|
||||
slug = models.CharField(max_length=128, unique=True)
|
||||
|
||||
class Meta(object):
|
||||
class Meta:
|
||||
ordering = ["name"]
|
||||
|
||||
def __str__(self):
|
||||
|
Reference in New Issue
Block a user