Initial commit, setup database

This commit is contained in:
Emmy D'Anello 2024-01-26 01:31:14 +01:00
commit 2d3eea114a
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
16 changed files with 1673 additions and 0 deletions

49
.gitignore vendored Normal file
View File

@ -0,0 +1,49 @@
# Byte-compiled / optimized / DLL files
dist
build
__pycache__
*.py[cod]
*$py.class
*.swp
*.egg-info
_build
.tox
.coverage
coverage
# Translations
*.mo
*.pot
# Jupyter Notebook
.ipynb_checkpoints
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# PyCharm project settings
.idea
# VSCode project settings
.vscode
# Local data
secrets.py
*.log
media/
output/
/static/
# Virtualenv
.env/
env/
.venv/
venv/
db.sqlite3
# Don't git index
whoosh_index/

22
manage.py Executable file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sncf.settings")
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == "__main__":
main()

0
sncf/__init__.py Normal file
View File

16
sncf/asgi.py Normal file
View File

@ -0,0 +1,16 @@
"""
ASGI config for sncf project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/5.0/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sncf.settings")
application = get_asgi_application()

125
sncf/settings.py Normal file
View File

@ -0,0 +1,125 @@
"""
Django settings for sncf project.
Generated by 'django-admin startproject' using Django 5.0.1.
For more information on this file, see
https://docs.djangoproject.com/en/5.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/5.0/ref/settings/
"""
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = "django-insecure-&900+#-_$xydt$nz3xe_6pe&*f#=7hiqal6@ndtt7v2oixhu@y"
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"sncfgtfs",
]
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]
ROOT_URLCONF = "sncf.urls"
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
},
},
]
WSGI_APPLICATION = "sncf.wsgi.application"
# Database
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
}
# Password validation
# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
},
{
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
},
{
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
},
{
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
},
]
# Internationalization
# https://docs.djangoproject.com/en/5.0/topics/i18n/
LANGUAGE_CODE = "fr-fr"
TIME_ZONE = "Europe/Paris"
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/5.0/howto/static-files/
STATIC_URL = "static/"
# Default primary key field type
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"

22
sncf/urls.py Normal file
View File

@ -0,0 +1,22 @@
"""
URL configuration for sncf project.
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/5.0/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
urlpatterns = [
path("admin/", admin.site.urls),
]

16
sncf/wsgi.py Normal file
View File

@ -0,0 +1,16 @@
"""
WSGI config for sncf project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/5.0/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sncf.settings")
application = get_wsgi_application()

0
sncfgtfs/__init__.py Normal file
View File

3
sncfgtfs/admin.py Normal file
View File

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

6
sncfgtfs/apps.py Normal file
View File

@ -0,0 +1,6 @@
from django.apps import AppConfig
class SncfgtfsConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "sncfgtfs"

View File

@ -0,0 +1,433 @@
msgid ""
msgstr ""
"Project-Id-Version: 1.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-01-26 00:40+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Emmy D'Anello <ynerant@emy.lu>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: sncfgtfs/models.py:6
msgid "Stop/platform"
msgstr "Arrêt / quai"
#: sncfgtfs/models.py:7
msgid "Station"
msgstr "Gare"
#: sncfgtfs/models.py:8
msgid "Entrance/exit"
msgstr "Entrée / sortie"
#: sncfgtfs/models.py:9
msgid "Generic node"
msgstr "Nœud générique"
#: sncfgtfs/models.py:10
msgid "Boarding area"
msgstr "Zone d'embarquement"
#: sncfgtfs/models.py:14
msgid "No information"
msgstr "Pas d'information"
#: sncfgtfs/models.py:15
msgid "Possible"
msgstr "Possible"
#: sncfgtfs/models.py:16
msgid "Not possible"
msgstr "Impossible"
#: sncfgtfs/models.py:20
msgid "Regular"
msgstr "Régulier"
#: sncfgtfs/models.py:21
msgid "None"
msgstr "Aucun"
#: sncfgtfs/models.py:22
msgid "Must phone agency"
msgstr "Doit téléphoner à l'agence"
#: sncfgtfs/models.py:23
msgid "Must coordinate with driver"
msgstr "Doit se coordonner avec læ conducteurice"
#: sncfgtfs/models.py:27
msgid "Tram"
msgstr "Tram"
#: sncfgtfs/models.py:28
msgid "Metro"
msgstr "Métro"
#: sncfgtfs/models.py:29
msgid "Rail"
msgstr "Rail"
#: sncfgtfs/models.py:30
msgid "Bus"
msgstr "Bus"
#: sncfgtfs/models.py:31
msgid "Ferry"
msgstr "Ferry"
#: sncfgtfs/models.py:32
msgid "Cable car"
msgstr "Câble"
#: sncfgtfs/models.py:33
msgid "Gondola"
msgstr "Gondole"
#: sncfgtfs/models.py:34
msgid "Funicular"
msgstr "Funiculaire"
#: sncfgtfs/models.py:38
msgid "Outbound"
msgstr "Vers l'extérieur"
#: sncfgtfs/models.py:39
msgid "Inbound"
msgstr "Vers l'intérieur"
#: sncfgtfs/models.py:46 sncfgtfs/models.py:170
msgid "Agency ID"
msgstr "ID de l'agence"
#: sncfgtfs/models.py:52
msgid "Agency name"
msgstr "Nom de l'agence"
#: sncfgtfs/models.py:56
msgid "Agency URL"
msgstr "URL de l'agence"
#: sncfgtfs/models.py:61
msgid "Agency timezone"
msgstr "Fuseau horaire de l'agence"
#: sncfgtfs/models.py:66
msgid "Agency language"
msgstr "Langue de l'agence"
#: sncfgtfs/models.py:71
msgid "Agency"
msgstr "Agence"
#: sncfgtfs/models.py:72
msgid "Agencies"
msgstr "Agences"
#: sncfgtfs/models.py:79 sncfgtfs/models.py:300
msgid "Stop ID"
msgstr "ID de l'arrêt"
#: sncfgtfs/models.py:84
msgid "Stop code"
msgstr "Code de l'arrêt"
#: sncfgtfs/models.py:90
msgid "Stop name"
msgstr "Nom de l'arrêt"
#: sncfgtfs/models.py:95
msgid "Stop description"
msgstr "Description de l'arrêt"
#: sncfgtfs/models.py:100
msgid "Stop longitude"
msgstr "Longitude de l'arrêt"
#: sncfgtfs/models.py:104
msgid "Stop latitude"
msgstr "Latitude de l'arrêt"
#: sncfgtfs/models.py:109
msgid "Zone ID"
msgstr "ID de la zone"
#: sncfgtfs/models.py:113
msgid "Stop URL"
msgstr "URL de l'arrêt"
#: sncfgtfs/models.py:118
msgid "Location type"
msgstr "Type de localisation"
#: sncfgtfs/models.py:127
msgid "Parent station"
msgstr "Gare parente"
#: sncfgtfs/models.py:133
msgid "Stop timezone"
msgstr "Fuseau horaire de l'arrêt"
#: sncfgtfs/models.py:139
msgid "Level ID"
msgstr "ID du niveau"
#: sncfgtfs/models.py:144
msgid "Wheelchair boarding"
msgstr "Embarquement en fauteuil roulant"
#: sncfgtfs/models.py:152
msgid "Platform code"
msgstr "Code du quai"
#: sncfgtfs/models.py:156
msgid "Stop"
msgstr "Arrêt"
#: sncfgtfs/models.py:157
msgid "Stops"
msgstr "Arrêts"
#: sncfgtfs/models.py:164 sncfgtfs/models.py:226
msgid "Route ID"
msgstr "ID de la ligne"
#: sncfgtfs/models.py:175
msgid "Route short name"
msgstr "Nom court de la ligne"
#: sncfgtfs/models.py:180
msgid "Route long name"
msgstr "Nom long de la ligne"
#: sncfgtfs/models.py:185
msgid "Route description"
msgstr "Description de la ligne"
#: sncfgtfs/models.py:190
msgid "Route type"
msgstr "Type de ligne"
#: sncfgtfs/models.py:195
msgid "Route URL"
msgstr "URL de la ligne"
#: sncfgtfs/models.py:201
msgid "Route color"
msgstr "Couleur de la ligne"
#: sncfgtfs/models.py:207
msgid "Route text color"
msgstr "Couleur du texte de la ligne"
#: sncfgtfs/models.py:212
msgid "Route"
msgstr "Ligne"
#: sncfgtfs/models.py:213
msgid "Routes"
msgstr "Lignes"
#: sncfgtfs/models.py:220 sncfgtfs/models.py:286
msgid "Trip ID"
msgstr "ID du trajet"
#: sncfgtfs/models.py:231 sncfgtfs/models.py:342 sncfgtfs/models.py:390
msgid "Service ID"
msgstr "ID du service"
#: sncfgtfs/models.py:236
msgid "Trip headsign"
msgstr "Destination du trajet"
#: sncfgtfs/models.py:242
msgid "Trip short name"
msgstr "Nom court du trajet"
#: sncfgtfs/models.py:247
msgid "Direction"
msgstr "Direction"
#: sncfgtfs/models.py:254
msgid "Block ID"
msgstr "ID du bloc"
#: sncfgtfs/models.py:260
msgid "Shape ID"
msgstr "ID de la forme"
#: sncfgtfs/models.py:265
msgid "Wheelchair accessible"
msgstr "Accessible en fauteuil roulant"
#: sncfgtfs/models.py:272
msgid "Bikes allowed"
msgstr "Vélos autorisés"
#: sncfgtfs/models.py:278
msgid "Trip"
msgstr "Trajet"
#: sncfgtfs/models.py:279
msgid "Trips"
msgstr "Trajets"
#: sncfgtfs/models.py:290
msgid "Arrival time"
msgstr "Heure d'arrivée"
#: sncfgtfs/models.py:294
msgid "Departure time"
msgstr "Heure de départ"
#: sncfgtfs/models.py:304
msgid "Stop sequence"
msgstr "Séquence de l'arrêt"
#: sncfgtfs/models.py:309
msgid "Stop headsign"
msgstr "Destination de l'arrêt"
#: sncfgtfs/models.py:314
msgid "Pickup type"
msgstr "Type de prise en charge"
#: sncfgtfs/models.py:321
msgid "Drop off type"
msgstr "Type de dépose"
#: sncfgtfs/models.py:328
msgid "Timepoint"
msgstr "Ponctualité"
#: sncfgtfs/models.py:334
msgid "Stop time"
msgstr "Heure d'arrêt"
#: sncfgtfs/models.py:335
msgid "Stop times"
msgstr "Heures d'arrêt"
#: sncfgtfs/models.py:346
msgid "Monday"
msgstr "Lundi"
#: sncfgtfs/models.py:350
msgid "Tuesday"
msgstr "Mardi"
#: sncfgtfs/models.py:354
msgid "Wednesday"
msgstr "Mercredi"
#: sncfgtfs/models.py:358
msgid "Thursday"
msgstr "Jeudi"
#: sncfgtfs/models.py:362
msgid "Friday"
msgstr "Vendredi"
#: sncfgtfs/models.py:366
msgid "Saturday"
msgstr "Samedi"
#: sncfgtfs/models.py:370
msgid "Sunday"
msgstr "Dimanche"
#: sncfgtfs/models.py:374
msgid "Start date"
msgstr "Date de début"
#: sncfgtfs/models.py:378
msgid "End date"
msgstr "Date de fin"
#: sncfgtfs/models.py:382
msgid "Calendar"
msgstr "Calendrier"
#: sncfgtfs/models.py:383
msgid "Calendars"
msgstr "Calendriers"
#: sncfgtfs/models.py:394
msgid "Date"
msgstr "Date"
#: sncfgtfs/models.py:398
msgid "Exception type"
msgstr "Type d'exception"
#: sncfgtfs/models.py:402
msgid "Calendar date"
msgstr "Date du calendrier"
#: sncfgtfs/models.py:403
msgid "Calendar dates"
msgstr "Dates du calendrier"
#: sncfgtfs/models.py:410
msgid "From stop"
msgstr "Depuis l'arrêt"
#: sncfgtfs/models.py:417
msgid "To stop"
msgstr "Jusqu'à l'arrêt"
#: sncfgtfs/models.py:422
msgid "Transfer type"
msgstr "Type de correspondance"
#: sncfgtfs/models.py:426
msgid "Minimum transfer time"
msgstr "Temps de correspondance minimum"
#: sncfgtfs/models.py:431
msgid "Transfer"
msgstr "Correspondance"
#: sncfgtfs/models.py:432
msgid "Transfers"
msgstr "Correspondances"
#: sncfgtfs/models.py:438
msgid "Feed ID"
msgstr "ID du flux"
#: sncfgtfs/models.py:443
msgid "Feed publisher name"
msgstr "Nom de l'éditeur du flux"
#: sncfgtfs/models.py:447
msgid "Feed publisher URL"
msgstr "URL de l'éditeur du flux"
#: sncfgtfs/models.py:452
msgid "Feed language"
msgstr "Langue du flux"
#: sncfgtfs/models.py:456
msgid "Feed start date"
msgstr "Date de début du flux"
#: sncfgtfs/models.py:460
msgid "Feed end date"
msgstr "Date de fin du flux"
#: sncfgtfs/models.py:465
msgid "Feed version"
msgstr "Version du flux"
#: sncfgtfs/models.py:469
msgid "Feed info"
msgstr "Information du flux"
#: sncfgtfs/models.py:470
msgid "Feed infos"
msgstr "Informations du flux"

View File

@ -0,0 +1,505 @@
# Generated by Django 5.0.1 on 2024-01-25 23:38
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = []
operations = [
migrations.CreateModel(
name="Agency",
fields=[
(
"agency_id",
models.CharField(
max_length=255,
primary_key=True,
serialize=False,
verbose_name="Agency ID",
),
),
(
"agency_name",
models.CharField(
max_length=255, unique=True, verbose_name="Agency name"
),
),
("agency_url", models.URLField(verbose_name="Agency URL")),
(
"agency_timezone",
models.CharField(max_length=255, verbose_name="Agency timezone"),
),
(
"agency_lang",
models.CharField(
blank=True, max_length=255, verbose_name="Agency language"
),
),
],
options={
"verbose_name": "Agency",
"verbose_name_plural": "Agencies",
},
),
migrations.CreateModel(
name="Calendar",
fields=[
(
"service_id",
models.CharField(
max_length=255,
primary_key=True,
serialize=False,
verbose_name="Service ID",
),
),
("monday", models.BooleanField(verbose_name="Monday")),
("tuesday", models.BooleanField(verbose_name="Tuesday")),
("wednesday", models.BooleanField(verbose_name="Wednesday")),
("thursday", models.BooleanField(verbose_name="Thursday")),
("friday", models.BooleanField(verbose_name="Friday")),
("saturday", models.BooleanField(verbose_name="Saturday")),
("sunday", models.BooleanField(verbose_name="Sunday")),
("start_date", models.DateField(verbose_name="Start date")),
("end_date", models.DateField(verbose_name="End date")),
],
options={
"verbose_name": "Calendar",
"verbose_name_plural": "Calendars",
},
),
migrations.CreateModel(
name="FeedInfo",
fields=[
(
"feed_id",
models.SmallIntegerField(
primary_key=True, serialize=False, verbose_name="Feed ID"
),
),
(
"feed_publisher_name",
models.CharField(
max_length=255, verbose_name="Feed publisher name"
),
),
(
"feed_publisher_url",
models.URLField(verbose_name="Feed publisher URL"),
),
(
"feed_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")),
(
"feed_version",
models.CharField(max_length=255, verbose_name="Feed version"),
),
],
options={
"verbose_name": "Feed info",
"verbose_name_plural": "Feed infos",
},
),
migrations.CreateModel(
name="CalendarDate",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("date", models.DateField(verbose_name="Date")),
("exception_type", models.IntegerField(verbose_name="Exception type")),
(
"service_id",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="sncfgtfs.calendar",
verbose_name="Service ID",
),
),
],
options={
"verbose_name": "Calendar date",
"verbose_name_plural": "Calendar dates",
},
),
migrations.CreateModel(
name="Route",
fields=[
(
"route_id",
models.CharField(
max_length=255,
primary_key=True,
serialize=False,
verbose_name="Route ID",
),
),
(
"route_short_name",
models.CharField(max_length=255, verbose_name="Route short name"),
),
(
"route_long_name",
models.CharField(max_length=255, verbose_name="Route long name"),
),
(
"route_desc",
models.CharField(
blank=True, max_length=255, verbose_name="Route description"
),
),
(
"route_type",
models.IntegerField(
choices=[
(0, "Tram"),
(1, "Metro"),
(2, "Rail"),
(3, "Bus"),
(4, "Ferry"),
(5, "Cable car"),
(6, "Gondola"),
(7, "Funicular"),
],
verbose_name="Route type",
),
),
("route_url", models.URLField(blank=True, verbose_name="Route URL")),
(
"route_color",
models.CharField(
blank=True, max_length=255, verbose_name="Route color"
),
),
(
"route_text_color",
models.CharField(
blank=True, max_length=255, verbose_name="Route text color"
),
),
(
"agency",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="sncfgtfs.agency",
verbose_name="Agency ID",
),
),
],
options={
"verbose_name": "Route",
"verbose_name_plural": "Routes",
},
),
migrations.CreateModel(
name="Stop",
fields=[
(
"stop_id",
models.CharField(
max_length=255,
primary_key=True,
serialize=False,
verbose_name="Stop ID",
),
),
(
"stop_code",
models.CharField(
blank=True, max_length=255, verbose_name="Stop code"
),
),
(
"stop_name",
models.CharField(max_length=255, verbose_name="Stop name"),
),
(
"stop_desc",
models.CharField(
blank=True, max_length=255, verbose_name="Stop description"
),
),
("stop_lon", models.FloatField(verbose_name="Stop longitude")),
("stop_lat", models.FloatField(verbose_name="Stop latitude")),
("zone_id", models.CharField(max_length=255, verbose_name="Zone ID")),
("stop_url", models.URLField(blank=True, verbose_name="Stop URL")),
(
"location_type",
models.IntegerField(
blank=True,
choices=[
(0, "Stop/platform"),
(1, "Station"),
(2, "Entrance/exit"),
(3, "Generic node"),
(4, "Boarding area"),
],
default=0,
verbose_name="Location type",
),
),
(
"stop_timezone",
models.CharField(
blank=True, max_length=255, verbose_name="Stop timezone"
),
),
(
"level_id",
models.CharField(
blank=True, max_length=255, verbose_name="Level ID"
),
),
(
"wheelchair_boarding",
models.IntegerField(
blank=True,
choices=[
(0, "No information"),
(1, "Possible"),
(2, "Not possible"),
],
default=0,
verbose_name="Wheelchair boarding",
),
),
(
"platform_code",
models.CharField(max_length=255, verbose_name="Platform code"),
),
(
"parent_station",
models.ForeignKey(
blank=True,
on_delete=django.db.models.deletion.PROTECT,
to="sncfgtfs.stop",
verbose_name="Parent station",
),
),
],
options={
"verbose_name": "Stop",
"verbose_name_plural": "Stops",
},
),
migrations.CreateModel(
name="Transfer",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("transfer_type", models.IntegerField(verbose_name="Transfer type")),
(
"min_transfer_time",
models.IntegerField(
blank=True, verbose_name="Minimum transfer time"
),
),
(
"from_stop",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="transfers_from",
to="sncfgtfs.stop",
verbose_name="From stop ID",
),
),
(
"to_stop",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="transfers_to",
to="sncfgtfs.stop",
verbose_name="To stop ID",
),
),
],
options={
"verbose_name": "Transfer",
"verbose_name_plural": "Transfers",
},
),
migrations.CreateModel(
name="Trip",
fields=[
(
"trip_id",
models.CharField(
max_length=255,
primary_key=True,
serialize=False,
verbose_name="Trip ID",
),
),
(
"service_id",
models.CharField(max_length=255, verbose_name="Service ID"),
),
(
"trip_headsign",
models.CharField(
blank=True, max_length=255, verbose_name="Trip headsign"
),
),
(
"trip_short_name",
models.CharField(
blank=True, max_length=255, verbose_name="Trip short name"
),
),
(
"direction_id",
models.IntegerField(
blank=True,
choices=[(0, "Outbound"), (1, "Inbound")],
verbose_name="Direction",
),
),
(
"block_id",
models.CharField(
blank=True, max_length=255, verbose_name="Block ID"
),
),
(
"shape_id",
models.CharField(
blank=True, max_length=255, verbose_name="Shape ID"
),
),
(
"wheelchair_accessible",
models.IntegerField(
blank=True,
choices=[
(0, "No information"),
(1, "Possible"),
(2, "Not possible"),
],
default=0,
verbose_name="Wheelchair accessible",
),
),
(
"bikes_allowed",
models.IntegerField(
choices=[
(0, "No information"),
(1, "Possible"),
(2, "Not possible"),
],
default=0,
verbose_name="Bikes allowed",
),
),
(
"route",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="sncfgtfs.route",
verbose_name="Route ID",
),
),
],
options={
"verbose_name": "Trip",
"verbose_name_plural": "Trips",
},
),
migrations.CreateModel(
name="StopTime",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("arrival_time", models.TimeField(verbose_name="Arrival time")),
("departure_time", models.TimeField(verbose_name="Departure time")),
("stop_sequence", models.IntegerField(verbose_name="Stop sequence")),
(
"stop_headsign",
models.CharField(
blank=True, max_length=255, verbose_name="Stop headsign"
),
),
(
"pickup_type",
models.IntegerField(
blank=True,
choices=[
(0, "Regular"),
(1, "None"),
(2, "Must phone agency"),
(3, "Must coordinate with driver"),
],
default=0,
verbose_name="Pickup type",
),
),
(
"drop_off_type",
models.IntegerField(
blank=True,
choices=[
(0, "Regular"),
(1, "None"),
(2, "Must phone agency"),
(3, "Must coordinate with driver"),
],
default=0,
verbose_name="Drop off type",
),
),
(
"timepoint",
models.BooleanField(
blank=True, default=True, verbose_name="Timepoint"
),
),
(
"stop",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="sncfgtfs.stop",
verbose_name="Stop ID",
),
),
(
"trip_id",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="sncfgtfs.trip",
verbose_name="Trip ID",
),
),
],
options={
"verbose_name": "Stop time",
"verbose_name_plural": "Stop times",
},
),
]

View File

470
sncfgtfs/models.py Normal file
View File

@ -0,0 +1,470 @@
from django.db import models
from django.utils.translation import gettext_lazy as _
class LocationType(models.IntegerChoices):
STOP_PLATFORM = 0, _("Stop/platform")
STATION = 1, _("Station")
ENTRANCE_EXIT = 2, _("Entrance/exit")
GENERIC_NODE = 3, _("Generic node")
BOARDING_AREA = 4, _("Boarding area")
class AccessInformation(models.IntegerChoices):
NO_INFORMATION = 0, _("No information")
POSSIBLE = 1, _("Possible")
NOT_POSSIBLE = 2, _("Not possible")
class PickupType(models.IntegerChoices):
REGULAR = 0, _("Regular")
NONE = 1, _("None")
MUST_PHONE_AGENCY = 2, _("Must phone agency")
MUST_COORDINATE_WITH_DRIVER = 3, _("Must coordinate with driver")
class RouteType(models.IntegerChoices):
TRAM = 0, _("Tram")
METRO = 1, _("Metro")
RAIL = 2, _("Rail")
BUS = 3, _("Bus")
FERRY = 4, _("Ferry")
CABLE_CAR = 5, _("Cable car")
GONDOLA = 6, _("Gondola")
FUNICULAR = 7, _("Funicular")
class Direction(models.IntegerChoices):
OUTBOUND = 0, _("Outbound")
INBOUND = 1, _("Inbound")
class Agency(models.Model):
agency_id = models.CharField(
max_length=255,
primary_key=True,
verbose_name=_("Agency ID"),
)
agency_name = models.CharField(
max_length=255,
unique=True,
verbose_name=_("Agency name"),
)
agency_url = models.URLField(
verbose_name=_("Agency URL"),
)
agency_timezone = models.CharField(
max_length=255,
verbose_name=_("Agency timezone"),
)
agency_lang = models.CharField(
max_length=255,
verbose_name=_("Agency language"),
blank=True,
)
class Meta:
verbose_name = _("Agency")
verbose_name_plural = _("Agencies")
class Stop(models.Model):
stop_id = models.CharField(
max_length=255,
primary_key=True,
verbose_name=_("Stop ID"),
)
stop_code = models.CharField(
max_length=255,
verbose_name=_("Stop code"),
blank=True,
)
stop_name = models.CharField(
max_length=255,
verbose_name=_("Stop name"),
)
stop_desc = models.CharField(
max_length=255,
verbose_name=_("Stop description"),
blank=True,
)
stop_lon = models.FloatField(
verbose_name=_("Stop longitude"),
)
stop_lat = models.FloatField(
verbose_name=_("Stop latitude"),
)
zone_id = models.CharField(
max_length=255,
verbose_name=_("Zone ID"),
)
stop_url = models.URLField(
verbose_name=_("Stop URL"),
blank=True,
)
location_type = models.IntegerField(
verbose_name=_("Location type"),
blank=True,
choices=LocationType,
default=LocationType.STOP_PLATFORM,
)
parent_station = models.ForeignKey(
to="Stop",
on_delete=models.PROTECT,
verbose_name=_("Parent station"),
blank=True,
)
stop_timezone = models.CharField(
max_length=255,
verbose_name=_("Stop timezone"),
blank=True,
)
level_id = models.CharField(
max_length=255,
verbose_name=_("Level ID"),
blank=True,
)
wheelchair_boarding = models.IntegerField(
verbose_name=_("Wheelchair boarding"),
blank=True,
choices=AccessInformation,
default=AccessInformation.NO_INFORMATION,
)
platform_code = models.CharField(
max_length=255,
verbose_name=_("Platform code"),
)
class Meta:
verbose_name = _("Stop")
verbose_name_plural = _("Stops")
class Route(models.Model):
route_id = models.CharField(
max_length=255,
primary_key=True,
verbose_name=_("Route ID"),
)
agency = models.ForeignKey(
to="Agency",
on_delete=models.CASCADE,
verbose_name=_("Agency ID"),
)
route_short_name = models.CharField(
max_length=255,
verbose_name=_("Route short name"),
)
route_long_name = models.CharField(
max_length=255,
verbose_name=_("Route long name"),
)
route_desc = models.CharField(
max_length=255,
verbose_name=_("Route description"),
blank=True,
)
route_type = models.IntegerField(
verbose_name=_("Route type"),
choices=RouteType,
)
route_url = models.URLField(
verbose_name=_("Route URL"),
blank=True,
)
route_color = models.CharField(
max_length=255,
verbose_name=_("Route color"),
blank=True,
)
route_text_color = models.CharField(
max_length=255,
verbose_name=_("Route text color"),
blank=True,
)
class Meta:
verbose_name = _("Route")
verbose_name_plural = _("Routes")
class Trip(models.Model):
trip_id = models.CharField(
max_length=255,
primary_key=True,
verbose_name=_("Trip ID"),
)
route = models.ForeignKey(
to="Route",
on_delete=models.CASCADE,
verbose_name=_("Route ID"),
)
service_id = models.CharField(
max_length=255,
verbose_name=_("Service ID"),
)
trip_headsign = models.CharField(
max_length=255,
verbose_name=_("Trip headsign"),
blank=True,
)
trip_short_name = models.CharField(
max_length=255,
verbose_name=_("Trip short name"),
blank=True,
)
direction_id = models.IntegerField(
verbose_name=_("Direction"),
choices=Direction,
blank=True,
)
block_id = models.CharField(
max_length=255,
verbose_name=_("Block ID"),
blank=True,
)
shape_id = models.CharField(
max_length=255,
verbose_name=_("Shape ID"),
blank=True,
)
wheelchair_accessible = models.IntegerField(
verbose_name=_("Wheelchair accessible"),
choices=AccessInformation,
default=AccessInformation.NO_INFORMATION,
blank=True,
)
bikes_allowed = models.IntegerField(
verbose_name=_("Bikes allowed"),
choices=AccessInformation,
default=AccessInformation.NO_INFORMATION,
)
class Meta:
verbose_name = _("Trip")
verbose_name_plural = _("Trips")
class StopTime(models.Model):
trip_id = models.ForeignKey(
to="Trip",
on_delete=models.CASCADE,
verbose_name=_("Trip ID"),
)
arrival_time = models.TimeField(
verbose_name=_("Arrival time"),
)
departure_time = models.TimeField(
verbose_name=_("Departure time"),
)
stop = models.ForeignKey(
to="Stop",
on_delete=models.CASCADE,
verbose_name=_("Stop ID"),
)
stop_sequence = models.IntegerField(
verbose_name=_("Stop sequence"),
)
stop_headsign = models.CharField(
max_length=255,
verbose_name=_("Stop headsign"),
blank=True,
)
pickup_type = models.IntegerField(
verbose_name=_("Pickup type"),
choices=PickupType,
default=PickupType.REGULAR,
blank=True,
)
drop_off_type = models.IntegerField(
verbose_name=_("Drop off type"),
choices=PickupType,
default=PickupType.REGULAR,
blank=True,
)
timepoint = models.BooleanField(
verbose_name=_("Timepoint"),
default=True,
blank=True,
)
class Meta:
verbose_name = _("Stop time")
verbose_name_plural = _("Stop times")
class Calendar(models.Model):
service_id = models.CharField(
max_length=255,
primary_key=True,
verbose_name=_("Service ID"),
)
monday = models.BooleanField(
verbose_name=_("Monday"),
)
tuesday = models.BooleanField(
verbose_name=_("Tuesday"),
)
wednesday = models.BooleanField(
verbose_name=_("Wednesday"),
)
thursday = models.BooleanField(
verbose_name=_("Thursday"),
)
friday = models.BooleanField(
verbose_name=_("Friday"),
)
saturday = models.BooleanField(
verbose_name=_("Saturday"),
)
sunday = models.BooleanField(
verbose_name=_("Sunday"),
)
start_date = models.DateField(
verbose_name=_("Start date"),
)
end_date = models.DateField(
verbose_name=_("End date"),
)
class Meta:
verbose_name = _("Calendar")
verbose_name_plural = _("Calendars")
class CalendarDate(models.Model):
service_id = models.ForeignKey(
to="Calendar",
on_delete=models.CASCADE,
verbose_name=_("Service ID"),
)
date = models.DateField(
verbose_name=_("Date"),
)
exception_type = models.IntegerField(
verbose_name=_("Exception type"),
)
class Meta:
verbose_name = _("Calendar date")
verbose_name_plural = _("Calendar dates")
class Transfer(models.Model):
from_stop = models.ForeignKey(
to="Stop",
on_delete=models.CASCADE,
verbose_name=_("From stop"),
related_name="transfers_from",
)
to_stop = models.ForeignKey(
to="Stop",
on_delete=models.CASCADE,
verbose_name=_("To stop"),
related_name="transfers_to",
)
transfer_type = models.IntegerField(
verbose_name=_("Transfer type"),
)
min_transfer_time = models.IntegerField(
verbose_name=_("Minimum transfer time"),
blank=True,
)
class Meta:
verbose_name = _("Transfer")
verbose_name_plural = _("Transfers")
class FeedInfo(models.Model):
feed_id = models.SmallIntegerField(
primary_key=True,
verbose_name=_("Feed ID"),
)
feed_publisher_name = models.CharField(
max_length=255,
verbose_name=_("Feed publisher name"),
)
feed_publisher_url = models.URLField(
verbose_name=_("Feed publisher URL"),
)
feed_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"),
)
feed_version = models.CharField(
max_length=255,
verbose_name=_("Feed version"),
)
class Meta:
verbose_name = _("Feed info")
verbose_name_plural = _("Feed infos")

3
sncfgtfs/tests.py Normal file
View File

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

3
sncfgtfs/views.py Normal file
View File

@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.