from django.contrib import admin
from sets.admin import Admin_Trans_BaseModel
from .models import *
from modeltranslation.admin import TranslationAdmin

class Admin_Country(Admin_Trans_BaseModel):
    fieldsets = [
        [None, {
            'classes': ['wide'],
            'fields': [
                'name', 'enable', 'short_code', 'code',
            ]
        }]
    ]

    list_display = [
        'id', 'name', 'name_en', 'name_ru',
        'short_code', 'code',
        'enable', 'area_id', 'parsing_finished_DT',
        'order', 'modifiedDT', 'createDT']
    search_fields = ['id', 'name_en', 'name_ru', 'short_code', 'code']
admin.site.register(Country, Admin_Country)

class Admin_City(Admin_Trans_BaseModel):
    fieldsets = [
        [None, {
            'classes': ['wide'],
            'fields': [
                'name', 'enable', 'country',
            ]
        }]
    ]

    list_display = [
        'id', 'name', 'name_en', 'name_ru',
        'country',
        'enable', 'area_id', 'parsing_finished_DT',
        'order', 'modifiedDT', 'createDT']
    search_fields = ['id', 'name_en', 'name_ru', 'country__name']
    list_filter = ['country']
admin.site.register(City, Admin_City)

class Admin_Airport(Admin_Trans_BaseModel):
    fieldsets = [
        [None, {
            'classes': ['wide'],
            'fields': [
                'name', 'enable',
                'city', 'iata_code', 'icao_code',
                'international_name',
                # 'area_id'
            ]
        }]
    ]

    list_display = [
        'id', 'name', 'name_en', 'name_ru',
        'city', 'iata_code', 'icao_code',
        'international_name',
        'enable', 'area_id', 'parsing_finished_DT',
        'order', 'modifiedDT', 'createDT']
    search_fields = ['id', 'name_en', 'name_ru', 'city__name', 'city__country__name', 'iata_code', 'icao_code', 'international_name']
    list_filter = ['city__country']
    raw_id_fields = [
        'city'
    ]

admin.site.register(Airport, Admin_Airport)