Better line display

This commit is contained in:
Emmy D'Anello 2024-01-27 13:41:34 +01:00
parent 56bd1765df
commit 119d0bf635
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
2 changed files with 77 additions and 7 deletions

View File

@ -321,9 +321,54 @@ class Trip(models.Model):
null=True,
)
@property
def origin(self):
return self.stop_times.order_by('stop_sequence').first().stop
@property
def destination(self):
return self.stop_times.order_by('-stop_sequence').first().stop.name
return self.stop_times.order_by('-stop_sequence').first().stop
@property
def train_type(self):
if self.service.transport_type == TransportType.TRANSILIEN:
return self.route.short_name
else:
train_type = self.origin.id.split('StopPoint:OCE')[1].split('-')[0]
if train_type == "Train TER":
train_type = "TER"
elif train_type == "INTERCITES":
train_type = "INTER-CITÉS"
elif train_type == "INTERCITES de nuit":
train_type = "INTER-CITÉS de nuit"
return train_type
@property
def train_number(self):
if self.service.transport_type == TransportType.TRANSILIEN:
return self.short_name
else:
return self.headsign
@property
def color(self):
if self.route.color:
return self.route.color
elif self.train_type == "OUIGO":
return "E60075"
return "FFFFFF"
@property
def text_color(self):
if self.route.text_color:
return self.route.text_color
elif self.train_type == "OUIGO":
return "FFFFFF"
elif self.train_type == "TGV INOUI":
return "9B2743"
elif self.train_type == "INTER-CITÉS" or self.train_type == "INTER-CITÉS de nuit":
return "404042"
return "000000"
def __str__(self):
return f"{self.route.long_name} - {self.id}"

View File

@ -34,17 +34,42 @@
<table class="table table-striped table-hover">
<thead>
<tr>
<th>Heure</th>
<th>Destination</th>
<th class="px-3 py-1" colspan="2">Train</th>
<th class="px-3 py-1">Heure</th>
<th class="px-3 py-1">Destination</th>
</tr>
</thead>
<tbody>
{% for departure in next_departures %}
<tr>
<td>{{ departure.pretty_departure_time }}</td>
<tr class="h-100">
<td class="h-100">
<div class="train-type d-flex h-100 align-items-center justify-content-center">
<div class="transilien-route d-flex align-items-center justify-content-center font-weight-bold small p-1 m-2 text-center text-wrap"
style="width: 4em; height: 4em; border-radius: 15%; background-color: #{{ departure.trip.color|default:"FFFFFF" }}; color: #{{ departure.trip.text_color|default:"000000" }};">
{{ departure.trip.train_type }}
</div>
</div>
</td>
<td class="h-100">
<div class="train-number d-flex align-items-center justify-content-center h-100">
<div>
{% if departure.trip.service.transport_type == "TN" %}
<div class="text-center">{{ departure.trip.headsign }}</div>
{% endif %}
<div>{{ departure.trip.train_number }}</div>
</div>
</div>
</td>
<td>
<h3>{{ departure.trip.destination }}</h3>
{% for trip_stop in departure.trip.stop_times.all %}{% if trip_stop.stop_sequence > departure.stop_sequence %}{% if trip_stop.drop_off_type == 0 %}{{ trip_stop.stop.name }}{% if trip_stop.stop.name != departure.trip.destination %}, {% endif %}{% endif %}{% endif %}{% endfor %}
<div class="table-hour d-flex align-items-center justify-content-center text-warning font-weight-bold h-100">
{{ departure.pretty_departure_time }}
</div>
</td>
<td>
<h3 class="headline">{{ departure.trip.destination.name }}</h3>
<span class="stops">
{% for trip_stop in departure.trip.stop_times.all %}{% if trip_stop.stop_sequence > departure.stop_sequence %}{% if trip_stop.drop_off_type == 0 %}{{ trip_stop.stop.name }}{% if trip_stop.stop != departure.trip.destination %}, {% endif %}{% endif %}{% endif %}{% endfor %}
</span>
</td>
</tr>
{% endfor %}