Compare commits
No commits in common. "b8fd85e0f64c357b9a4121e788ed249f999a3f53" and "c60a105b2d0d2c065e4d3a294b74d689569b6e82" have entirely different histories.
b8fd85e0f6
...
c60a105b2d
@ -1,5 +1,4 @@
|
|||||||
from django.apps import AppConfig
|
from django.apps import AppConfig
|
||||||
from django.db.models.signals import pre_save
|
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
|
||||||
@ -7,8 +6,3 @@ class TrainvelGTFSConfig(AppConfig):
|
|||||||
default_auto_field = "django.db.models.BigAutoField"
|
default_auto_field = "django.db.models.BigAutoField"
|
||||||
name = "trainvel.gtfs"
|
name = "trainvel.gtfs"
|
||||||
verbose_name = _("Trainvel - GTFS")
|
verbose_name = _("Trainvel - GTFS")
|
||||||
|
|
||||||
def ready(self):
|
|
||||||
from trainvel.gtfs import signals
|
|
||||||
|
|
||||||
pre_save.connect(signals.keep_gtfs_feed_modification_date, sender="gtfs.GTFSFeed")
|
|
||||||
|
@ -368,7 +368,6 @@ class Command(BaseCommand):
|
|||||||
stop_times.clear()
|
stop_times.clear()
|
||||||
|
|
||||||
if os.path.exists(os.path.join(zip_dir, "transfers.txt")):
|
if os.path.exists(os.path.join(zip_dir, "transfers.txt")):
|
||||||
Transfer.objects.filter(Q(from_stop__gtfs_feed_id=gtfs_code) | Q(to_stop__gtfs_feed_id=gtfs_code)).delete()
|
|
||||||
transfers = []
|
transfers = []
|
||||||
for transfer_dict in read_csv("transfers.txt"):
|
for transfer_dict in read_csv("transfers.txt"):
|
||||||
transfer_dict: dict
|
transfer_dict: dict
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
from trainvel.gtfs.models import GTFSFeed
|
|
||||||
|
|
||||||
|
|
||||||
def keep_gtfs_feed_modification_date(instance: GTFSFeed, raw: bool = True, **_kwargs):
|
|
||||||
"""
|
|
||||||
Keep the last_modified and etag fields from the existing GTFSFeed instance when saving a new one.
|
|
||||||
"""
|
|
||||||
if raw and GTFSFeed.objects.filter(pk=instance.pk).exists():
|
|
||||||
# If a GTFSFeed instance is being saved from a raw query,
|
|
||||||
# we want to keep the last_modified and etag fields from the existing instance.
|
|
||||||
# This is useful when loading initial data from a fixture, for example.
|
|
||||||
old_instance = GTFSFeed.objects.get(pk=instance.pk)
|
|
||||||
instance.last_modified = old_instance.last_modified
|
|
||||||
instance.etag = old_instance.etag
|
|
Loading…
x
Reference in New Issue
Block a user