diff --git a/sncfgtfs/models.py b/sncfgtfs/models.py index 31fa95d..e37b49e 100644 --- a/sncfgtfs/models.py +++ b/sncfgtfs/models.py @@ -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}" diff --git a/sncfgtfs/templates/sncfgtfs/gare.html b/sncfgtfs/templates/sncfgtfs/gare.html index c8b2eaa..e737f78 100644 --- a/sncfgtfs/templates/sncfgtfs/gare.html +++ b/sncfgtfs/templates/sncfgtfs/gare.html @@ -34,17 +34,42 @@ - - + + + {% for departure in next_departures %} - - + + + + {% endfor %}
HeureDestinationTrainHeureDestination
{{ departure.pretty_departure_time }}
+
+
+ {{ departure.trip.train_type }} +
+
+
+
+
+ {% if departure.trip.service.transport_type == "TN" %} +
{{ departure.trip.headsign }}
+ {% endif %} +
{{ departure.trip.train_number }}
+
+
+
-

{{ departure.trip.destination }}

- {% 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 }} +
+
+

{{ departure.trip.destination.name }}

+ + {% 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 %} +