trainvel/sncfgtfs/admin.py

136 lines
4.6 KiB
Python

from django.contrib import admin
from sncfgtfs.models import Agency, Stop, Route, Trip, StopTime, Calendar, CalendarDate, \
Transfer, FeedInfo, StopTimeUpdate, TripUpdate
class CalendarDateInline(admin.TabularInline):
model = CalendarDate
extra = 0
class TripInline(admin.TabularInline):
model = Trip
extra = 0
autocomplete_fields = ('route', 'service',)
show_change_link = True
ordering = ('service',)
class StopTimeInline(admin.TabularInline):
model = StopTime
extra = 0
autocomplete_fields = ('stop',)
show_change_link = True
ordering = ('stop_sequence',)
class TripUpdateInline(admin.StackedInline):
model = TripUpdate
extra = 0
class StopTimeUpdateInline(admin.StackedInline):
model = StopTimeUpdate
extra = 0
@admin.register(Agency)
class AgencyAdmin(admin.ModelAdmin):
list_display = ('name', 'id', 'url', 'timezone',)
search_fields = ('name',)
@admin.register(Stop)
class StopAdmin(admin.ModelAdmin):
list_display = ('name', 'id', 'lat', 'lon', 'location_type',)
list_filter = ('location_type', 'transport_type',)
search_fields = ('name', 'id',)
ordering = ('name',)
autocomplete_fields = ('parent_station',)
@admin.register(Route)
class RouteAdmin(admin.ModelAdmin):
list_display = ('short_name', 'long_name', 'id', 'type',)
list_filter = ('transport_type', 'type', 'agency',)
search_fields = ('long_name', 'short_name', 'id',)
ordering = ('long_name',)
autocomplete_fields = ('agency',)
inlines = (TripInline,)
@admin.register(Trip)
class TripAdmin(admin.ModelAdmin):
list_display = ('id', 'route', 'service', 'headsign', 'direction_id',)
list_filter = ('direction_id', 'route__transport_type',)
search_fields = ('id', 'route__id', 'route__long_name', 'service__id', 'headsign',)
ordering = ('route', 'service',)
autocomplete_fields = ('route', 'service',)
inlines = (StopTimeInline, TripUpdateInline,)
@admin.register(StopTime)
class StopTimeAdmin(admin.ModelAdmin):
list_display = ('trip', 'stop', 'arrival_time', 'departure_time',
'stop_sequence', 'pickup_type', 'drop_off_type',)
list_filter = ('pickup_type', 'drop_off_type', 'trip__route__transport_type',)
search_fields = ('trip__id', 'stop__name', 'arrival_time', 'departure_time',)
ordering = ('trip', 'stop_sequence',)
autocomplete_fields = ('trip', 'stop',)
inlines = (StopTimeUpdateInline,)
@admin.register(Calendar)
class CalendarAdmin(admin.ModelAdmin):
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',)
inlines = (CalendarDateInline, TripInline,)
@admin.register(CalendarDate)
class CalendarDateAdmin(admin.ModelAdmin):
list_display = ('id', 'service_id', 'date', 'exception_type',)
list_filter = ('exception_type', 'date', 'service__transport_type',)
search_fields = ('id', 'date',)
ordering = ('date', 'service_id',)
@admin.register(Transfer)
class TransferAdmin(admin.ModelAdmin):
list_display = ('from_stop', 'to_stop', 'transfer_type', 'min_transfer_time',)
list_filter = ('transfer_type',)
search_fields = ('from_stop__name', 'to_stop__name',)
autocomplete_fields = ('from_stop', 'to_stop',)
@admin.register(FeedInfo)
class FeedInfoAdmin(admin.ModelAdmin):
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',)
@admin.register(StopTimeUpdate)
class StopTimeUpdateAdmin(admin.ModelAdmin):
list_display = ('trip_update', 'stop_time', 'arrival_delay', 'arrival_time',
'departure_delay', 'departure_time', 'schedule_relationship',)
list_filter = ('schedule_relationship',)
search_fields = ('trip_update__trip__id', 'stop_time__stop__name', 'arrival_time', 'departure_time',)
ordering = ('trip_update', 'stop_time',)
@admin.register(TripUpdate)
class TripUpdateAdmin(admin.ModelAdmin):
list_display = ('trip_id', 'start_date', 'start_time',)
list_filter = ('start_date', 'schedule_relationship',)
search_fields = ('trip__id', 'start_date', 'start_time',)
ordering = ('trip_id', 'start_date', 'start_time',)
autocomplete_fields = ('trip',)