Better line display
This commit is contained in:
parent
56bd1765df
commit
119d0bf635
|
@ -321,9 +321,54 @@ class Trip(models.Model):
|
||||||
null=True,
|
null=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def origin(self):
|
||||||
|
return self.stop_times.order_by('stop_sequence').first().stop
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def destination(self):
|
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):
|
def __str__(self):
|
||||||
return f"{self.route.long_name} - {self.id}"
|
return f"{self.route.long_name} - {self.id}"
|
||||||
|
|
|
@ -34,17 +34,42 @@
|
||||||
<table class="table table-striped table-hover">
|
<table class="table table-striped table-hover">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Heure</th>
|
<th class="px-3 py-1" colspan="2">Train</th>
|
||||||
<th>Destination</th>
|
<th class="px-3 py-1">Heure</th>
|
||||||
|
<th class="px-3 py-1">Destination</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for departure in next_departures %}
|
{% for departure in next_departures %}
|
||||||
<tr>
|
<tr class="h-100">
|
||||||
<td>{{ departure.pretty_departure_time }}</td>
|
<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>
|
<td>
|
||||||
<h3>{{ departure.trip.destination }}</h3>
|
<div class="table-hour d-flex align-items-center justify-content-center text-warning font-weight-bold h-100">
|
||||||
{% 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 %}
|
{{ 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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
Loading…
Reference in New Issue