Better line display
This commit is contained in:
@ -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}"
|
||||
|
Reference in New Issue
Block a user