From b6da0c54f78bf2ba1f7f863f4987bd22ec274b42 Mon Sep 17 00:00:00 2001 From: Emmy D'Anello Date: Sat, 27 Jan 2024 15:18:33 +0100 Subject: [PATCH] Rename feed field --- sncfgtfs/admin.py | 10 ++++---- .../management/commands/update_sncf_gtfs.py | 16 ++++++------ sncfgtfs/migrations/0001_initial.py | 25 +++++++++++-------- sncfgtfs/models.py | 20 ++++++++++----- 4 files changed, 42 insertions(+), 29 deletions(-) diff --git a/sncfgtfs/admin.py b/sncfgtfs/admin.py index f2a2621..53d0764 100644 --- a/sncfgtfs/admin.py +++ b/sncfgtfs/admin.py @@ -75,8 +75,8 @@ class TransferAdmin(admin.ModelAdmin): @admin.register(FeedInfo) class FeedInfoAdmin(admin.ModelAdmin): - list_display = ('feed_publisher_name', 'feed_publisher_url', 'feed_lang', 'feed_start_date', - 'feed_end_date', 'feed_version',) - search_fields = ('feed_publisher_name', 'feed_publisher_url', 'feed_lang', 'feed_start_date', - 'feed_end_date', 'feed_version',) - ordering = ('feed_publisher_name',) + list_display = ('publisher_name', 'publisher_url', 'lang', 'start_date', + 'end_date', 'version',) + search_fields = ('publisher_name', 'publisher_url', 'lang', 'start_date', + 'end_date', 'version',) + ordering = ('publisher_name',) diff --git a/sncfgtfs/management/commands/update_sncf_gtfs.py b/sncfgtfs/management/commands/update_sncf_gtfs.py index abd5d40..bc5affe 100644 --- a/sncfgtfs/management/commands/update_sncf_gtfs.py +++ b/sncfgtfs/management/commands/update_sncf_gtfs.py @@ -325,12 +325,12 @@ class Command(BaseCommand): for feed_info_dict in csv.DictReader(zipfile.read("feed_info.txt").decode().splitlines()): feed_info_dict: dict FeedInfo.objects.update_or_create( - feed_publisher_name=feed_info_dict['feed_publisher_name'], - defaults={ - 'feed_publisher_url': feed_info_dict['feed_publisher_url'], - 'feed_lang': feed_info_dict['feed_lang'], - 'feed_start_date': feed_info_dict['feed_start_date'], - 'feed_end_date': feed_info_dict['feed_end_date'], - 'feed_version': feed_info_dict['feed_version'], - } + publisher_name=feed_info_dict['feed_publisher_name'], + defaults=dict( + publisher_url=feed_info_dict['feed_publisher_url'], + lang=feed_info_dict['feed_lang'], + start_date=feed_info_dict['feed_start_date'], + end_date=feed_info_dict['feed_end_date'], + version=feed_info_dict['feed_version'], + ) ) diff --git a/sncfgtfs/migrations/0001_initial.py b/sncfgtfs/migrations/0001_initial.py index dcebf03..8c14914 100644 --- a/sncfgtfs/migrations/0001_initial.py +++ b/sncfgtfs/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 5.0.1 on 2024-01-27 10:29 +# Generated by Django 5.0.1 on 2024-01-27 14:08 import django.db.models.deletion from django.db import migrations, models @@ -55,6 +55,7 @@ class Migration(migrations.Migration): options={ "verbose_name": "Agency", "verbose_name_plural": "Agencies", + "ordering": ("name",), }, ), migrations.CreateModel( @@ -95,6 +96,7 @@ class Migration(migrations.Migration): options={ "verbose_name": "Calendar", "verbose_name_plural": "Calendars", + "ordering": ("id",), }, ), migrations.CreateModel( @@ -110,29 +112,27 @@ class Migration(migrations.Migration): ), ), ( - "feed_publisher_name", + "publisher_name", models.CharField( max_length=255, verbose_name="Feed publisher name" ), ), + ("publisher_url", models.URLField(verbose_name="Feed publisher URL")), ( - "feed_publisher_url", - models.URLField(verbose_name="Feed publisher URL"), - ), - ( - "feed_lang", + "lang", models.CharField(max_length=255, verbose_name="Feed language"), ), - ("feed_start_date", models.DateField(verbose_name="Feed start date")), - ("feed_end_date", models.DateField(verbose_name="Feed end date")), + ("start_date", models.DateField(verbose_name="Feed start date")), + ("end_date", models.DateField(verbose_name="Feed end date")), ( - "feed_version", + "version", models.CharField(max_length=255, verbose_name="Feed version"), ), ], options={ "verbose_name": "Feed info", "verbose_name_plural": "Feed infos", + "ordering": ("publisher_name",), }, ), migrations.CreateModel( @@ -181,6 +181,7 @@ class Migration(migrations.Migration): options={ "verbose_name": "Calendar date", "verbose_name_plural": "Calendar dates", + "ordering": ("id",), }, ), migrations.CreateModel( @@ -251,6 +252,7 @@ class Migration(migrations.Migration): options={ "verbose_name": "Route", "verbose_name_plural": "Routes", + "ordering": ("id",), }, ), migrations.CreateModel( @@ -343,6 +345,7 @@ class Migration(migrations.Migration): options={ "verbose_name": "Stop", "verbose_name_plural": "Stops", + "ordering": ("id",), }, ), migrations.CreateModel( @@ -398,6 +401,7 @@ class Migration(migrations.Migration): options={ "verbose_name": "Transfer", "verbose_name_plural": "Transfers", + "ordering": ("id",), }, ), migrations.CreateModel( @@ -492,6 +496,7 @@ class Migration(migrations.Migration): options={ "verbose_name": "Trip", "verbose_name_plural": "Trips", + "ordering": ("id",), }, ), migrations.CreateModel( diff --git a/sncfgtfs/models.py b/sncfgtfs/models.py index e37b49e..c8e555d 100644 --- a/sncfgtfs/models.py +++ b/sncfgtfs/models.py @@ -103,6 +103,7 @@ class Agency(models.Model): class Meta: verbose_name = _("Agency") verbose_name_plural = _("Agencies") + ordering = ("name",) class Stop(models.Model): @@ -194,6 +195,7 @@ class Stop(models.Model): class Meta: verbose_name = _("Stop") verbose_name_plural = _("Stops") + ordering = ("id",) class Route(models.Model): @@ -254,6 +256,7 @@ class Route(models.Model): class Meta: verbose_name = _("Route") verbose_name_plural = _("Routes") + ordering = ("id",) class Trip(models.Model): @@ -376,6 +379,7 @@ class Trip(models.Model): class Meta: verbose_name = _("Trip") verbose_name_plural = _("Trips") + ordering = ("id",) class StopTime(models.Model): @@ -514,6 +518,7 @@ class Calendar(models.Model): class Meta: verbose_name = _("Calendar") verbose_name_plural = _("Calendars") + ordering = ("id",) class CalendarDate(models.Model): @@ -551,6 +556,7 @@ class CalendarDate(models.Model): class Meta: verbose_name = _("Calendar date") verbose_name_plural = _("Calendar dates") + ordering = ("id",) class Transfer(models.Model): @@ -588,32 +594,33 @@ class Transfer(models.Model): class Meta: verbose_name = _("Transfer") verbose_name_plural = _("Transfers") + ordering = ("id",) class FeedInfo(models.Model): - feed_publisher_name = models.CharField( + publisher_name = models.CharField( max_length=255, verbose_name=_("Feed publisher name"), ) - feed_publisher_url = models.URLField( + publisher_url = models.URLField( verbose_name=_("Feed publisher URL"), ) - feed_lang = models.CharField( + lang = models.CharField( max_length=255, verbose_name=_("Feed language"), ) - feed_start_date = models.DateField( + start_date = models.DateField( verbose_name=_("Feed start date"), ) - feed_end_date = models.DateField( + end_date = models.DateField( verbose_name=_("Feed end date"), ) - feed_version = models.CharField( + version = models.CharField( max_length=255, verbose_name=_("Feed version"), ) @@ -621,3 +628,4 @@ class FeedInfo(models.Model): class Meta: verbose_name = _("Feed info") verbose_name_plural = _("Feed infos") + ordering = ("publisher_name",)