from django.contrib import admin
from django.contrib.gis import admin as gis_admin
from .models import OfficialKyosaiField, OfficialChusankanField, Field


@admin.register(OfficialKyosaiField)
class OfficialKyosaiFieldAdmin(admin.ModelAdmin):
    list_display = ('k_num', 's_num', 'kanji_name', 'address', 'area')
    search_fields = ('k_num', 'kanji_name', 'address')
    list_filter = ('s_num',)


@admin.register(OfficialChusankanField)
class OfficialChusankanFieldAdmin(admin.ModelAdmin):
    list_display = ('c_id', 'oaza', 'aza', 'chiban', 'area', 'payment_amount')
    search_fields = ('c_id', 'oaza', 'aza')
    list_filter = ('oaza',)


@admin.register(Field)
class FieldAdmin(gis_admin.GISModelAdmin):
    list_display = ('name', 'address', 'area_tan', 'area_m2', 'owner_name')
    search_fields = ('name', 'address', 'owner_name')
    list_filter = ('kyosai_fields', 'chusankan_fields')
    filter_horizontal = ('kyosai_fields', 'chusankan_fields')
    gis_widget_kwargs = {'attrs': {'static_map': False, 'longitude': 139.0, 'latitude': 36.0, 'zoom': 10}}
