Simplify consist cards cover generator

This commit is contained in:
2026-01-05 15:38:51 +01:00
parent 1be102b9d4
commit 7656aa8b68
2 changed files with 15 additions and 5 deletions

View File

@@ -56,6 +56,15 @@ class Consist(BaseModel):
order=models.Max("order"),
).order_by("order")
def get_cover(self):
if self.image:
return self.image
else:
consist_item = self.consist_item.first()
if consist_item and consist_item.rolling_stock.image.exists():
return consist_item.rolling_stock.image.first().image
return None
@property
def country(self):
return self.company.country