mirror of
https://github.com/daniviga/django-ram.git
synced 2025-10-19 09:00:32 +02:00
Minor admin improvements and remove unique_together deprecated Meta
Also make rolling stock unique per consist
This commit is contained in:
@@ -54,10 +54,20 @@ class ConsistItem(models.Model):
|
||||
Consist, on_delete=models.CASCADE, related_name="consist_item"
|
||||
)
|
||||
rolling_stock = models.ForeignKey(RollingStock, on_delete=models.CASCADE)
|
||||
order = models.PositiveIntegerField(default=0, blank=False, null=False)
|
||||
order = models.PositiveIntegerField(
|
||||
default=1000, # make sure it is always added at the end
|
||||
blank=False,
|
||||
null=False
|
||||
)
|
||||
|
||||
class Meta(object):
|
||||
class Meta:
|
||||
ordering = ["order"]
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=["consist", "rolling_stock"],
|
||||
name="one_stock_per_consist"
|
||||
)
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return "{0}".format(self.rolling_stock)
|
||||
|
Reference in New Issue
Block a user