18 lines
560 B
Python
18 lines
560 B
Python
from presenter.train_station import TrainStationPresenter
|
|
|
|
|
|
class TrainPresenter:
|
|
def __init__(self, data):
|
|
self.data = data
|
|
|
|
def as_dict(self):
|
|
return {
|
|
"id": self.data.id,
|
|
"trainNo": self.data.train_no,
|
|
"arrTime": self.data.arrival_time,
|
|
"depTime": self.data.departure_time,
|
|
"arr": self.data.arrival_station,
|
|
"dep": self.data.departure_station,
|
|
"stations": [TrainStationPresenter(station).as_dict() for station in self.data.train_stations]
|
|
}
|