mirror of
https://github.com/daniviga/django-ram.git
synced 2025-08-03 20:57: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
|
||||
|
@@ -57,7 +57,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Length</th>
|
||||
<td>{{ d.item.consist_item.count }}</td>
|
||||
<td>{{ d.item.length }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
@@ -109,7 +109,7 @@
|
||||
{% endif %}
|
||||
<tr>
|
||||
<th scope="row">Length</th>
|
||||
<td>{{ data | length }}</td>
|
||||
<td>{{ consist.length }}: {% for t in consist.get_type_count %}{{ t.count }}x {{ t.type }} {{t.category }}{% if not forloop.last %} + {% endif %}{% endfor %}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
from ram.utils import git_suffix
|
||||
|
||||
__version__ = "0.17.3"
|
||||
__version__ = "0.17.4"
|
||||
__version__ += git_suffix(__file__)
|
||||
|
Reference in New Issue
Block a user