From 368f07da327b3f2b351472d65415c4bea235eba0 Mon Sep 17 00:00:00 2001 From: Emmy D'Anello Date: Sat, 11 May 2024 21:10:04 +0200 Subject: [PATCH] Replace Transilien by IDFM source, add CTS (Strasbourg) --- trainvel/gtfs/fixtures/gtfs_feeds.json | 16 +++++++++++++--- .../management/commands/update_trainvel_gtfs.py | 4 +++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/trainvel/gtfs/fixtures/gtfs_feeds.json b/trainvel/gtfs/fixtures/gtfs_feeds.json index 158b49c..91e04f3 100644 --- a/trainvel/gtfs/fixtures/gtfs_feeds.json +++ b/trainvel/gtfs/fixtures/gtfs_feeds.json @@ -31,11 +31,21 @@ }, { "model": "gtfs.gtfsfeed", - "pk": "FR-IDF-TN", + "pk": "FR-IDF-IDFM", "fields": { - "name": "SNCF - Transilien", + "name": "Île-de-France Mobilités", "country": "FR", - "feed_url": "https://eu.ftp.opendatasoft.com/sncf/gtfs/transilien-gtfs.zip", + "feed_url": "https://data.iledefrance-mobilites.fr/api/v2/catalog/datasets/offre-horaires-tc-gtfs-idfm/files/a925e164271e4bca93433756d6a340d1", + "rt_feed_url": "" + } + }, + { + "model": "gtfs.gtfsfeed", + "pk": "FR-GES-CTS", + "fields": { + "name": "Compagnie des Transports Strasbourgeois (CTS)", + "country": "FR", + "feed_url": "https://opendata.cts-strasbourg.eu/google_transit.zip", "rt_feed_url": "" } }, diff --git a/trainvel/gtfs/management/commands/update_trainvel_gtfs.py b/trainvel/gtfs/management/commands/update_trainvel_gtfs.py index 9a58341..b653940 100644 --- a/trainvel/gtfs/management/commands/update_trainvel_gtfs.py +++ b/trainvel/gtfs/management/commands/update_trainvel_gtfs.py @@ -124,9 +124,11 @@ class Command(BaseCommand): route_dict: dict route_id = route_dict['route_id'] route_id = f"{gtfs_code}-{route_id}" + # Agency is optional there is only one + agency_id = route_dict.get('agency_id', "") or Agency.objects.get(gtfs_feed=gtfs_feed) route = Route( id=route_id, - agency_id=f"{gtfs_code}-{route_dict['agency_id']}", + agency_id=f"{gtfs_code}-{agency_id}", short_name=route_dict['route_short_name'], long_name=route_dict['route_long_name'], desc=route_dict.get('route_desc', ""),