mirror of
https://github.com/daniviga/django-ram.git
synced 2025-08-04 13:17:50 +02:00
Provide consist composition
This commit is contained in:
@@ -39,6 +39,20 @@ class Consist(BaseModel):
|
||||
def get_absolute_url(self):
|
||||
return reverse("consist", kwargs={"uuid": self.uuid})
|
||||
|
||||
@property
|
||||
def length(self):
|
||||
return self.consist_item.count()
|
||||
|
||||
def get_type_count(self):
|
||||
return self.consist_item.annotate(
|
||||
type=models.F("rolling_stock__rolling_class__type__type")
|
||||
).values(
|
||||
"type"
|
||||
).annotate(
|
||||
count=models.Count("rolling_stock"),
|
||||
category=models.F("rolling_stock__rolling_class__type__category")
|
||||
).order_by("rolling_stock__rolling_class__type__order")
|
||||
|
||||
@property
|
||||
def country(self):
|
||||
return self.company.country
|
||||
|
Reference in New Issue
Block a user