trainvel/sncfgtfs/admin.py

83 lines
3.0 KiB
Python
Raw Normal View History

2024-01-26 00:31:14 +00:00
from django.contrib import admin
2024-01-27 09:45:34 +00:00
from django.utils.safestring import mark_safe
2024-01-26 00:31:14 +00:00
2024-01-26 20:06:00 +00:00
from sncfgtfs.models import Agency, Stop, Route, Trip, StopTime, Calendar, CalendarDate, \
Transfer, FeedInfo
@admin.register(Agency)
class AgencyAdmin(admin.ModelAdmin):
2024-01-27 09:45:34 +00:00
list_display = ('name', 'id', 'url', 'timezone',)
search_fields = ('name',)
2024-01-26 20:06:00 +00:00
@admin.register(Stop)
class StopAdmin(admin.ModelAdmin):
2024-01-27 09:45:34 +00:00
list_display = ('name', 'id', 'lat', 'lon', 'location_type',)
list_filter = ('location_type',)
search_fields = ('name', 'id',)
ordering = ('name',)
autocomplete_fields = ('parent_station',)
2024-01-26 20:06:00 +00:00
@admin.register(Route)
class RouteAdmin(admin.ModelAdmin):
2024-01-27 09:45:34 +00:00
list_display = ('long_name', 'short_name', 'id', 'type',)
list_filter = ('type',)
search_fields = ('long_name', 'short_name', 'id',)
ordering = ('long_name',)
autocomplete_fields = ('agency',)
2024-01-26 20:06:00 +00:00
@admin.register(Trip)
class TripAdmin(admin.ModelAdmin):
2024-01-27 09:45:34 +00:00
list_display = ('id', 'route', 'service', 'headsign', 'direction_id',)
list_filter = ('direction_id', 'service__transport_type',)
search_fields = ('id', 'route__long_name', 'service', 'headsign',)
ordering = ('route', 'service',)
2024-01-26 20:06:00 +00:00
@admin.register(StopTime)
class StopTimeAdmin(admin.ModelAdmin):
2024-01-27 10:43:01 +00:00
list_display = ('trip', 'stop', 'arrival_time', 'departure_time',
2024-01-27 09:45:34 +00:00
'stop_sequence', 'pickup_type', 'drop_off_type',)
2024-01-27 10:43:01 +00:00
list_filter = ('pickup_type', 'drop_off_type', 'trip__service__transport_type',)
2024-01-27 09:45:34 +00:00
search_fields = ('trip__id', 'stop__name', 'arrival_time', 'departure_time',)
ordering = ('trip', 'stop_sequence',)
autocomplete_fields = ('trip', 'stop',)
2024-01-26 20:06:00 +00:00
@admin.register(Calendar)
class CalendarAdmin(admin.ModelAdmin):
2024-01-27 09:45:34 +00:00
list_display = ('id', 'transport_type', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday',
'saturday', 'sunday', 'start_date', 'end_date',)
list_filter = ('transport_type', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday',
'start_date', 'end_date',)
search_fields = ('id', 'start_date', 'end_date',)
ordering = ('transport_type', 'id',)
2024-01-26 20:06:00 +00:00
@admin.register(CalendarDate)
class CalendarDateAdmin(admin.ModelAdmin):
2024-01-27 09:45:34 +00:00
list_display = ('id', 'service_id', 'date', 'exception_type',)
list_filter = ('exception_type', 'date', 'service__transport_type',)
search_fields = ('id', 'date',)
ordering = ('date', 'service_id',)
2024-01-26 20:06:00 +00:00
@admin.register(Transfer)
class TransferAdmin(admin.ModelAdmin):
2024-01-27 09:45:34 +00:00
list_display = ('from_stop', 'to_stop', 'transfer_type', 'min_transfer_time',)
list_filter = ('transfer_type',)
2024-01-28 19:06:55 +00:00
search_fields = ('from_stop__name', 'to_stop__name',)
2024-01-27 09:45:34 +00:00
autocomplete_fields = ('from_stop', 'to_stop',)
2024-01-26 20:06:00 +00:00
@admin.register(FeedInfo)
class FeedInfoAdmin(admin.ModelAdmin):
2024-01-27 14:18:33 +00:00
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',)