from django.contrib import admin
from .models import Country, GeoScenario, OptScenario


@admin.register(Country)
class CountryAdmin(admin.ModelAdmin):
    list_display = ('code', 'name')
    search_fields = ('code', 'name')
    ordering = ('name',)


@admin.register(GeoScenario)
class GeoScenarioAdmin(admin.ModelAdmin):
    list_display = ('name', 'country', 'upload_date', 'geographic_field_name')
    list_filter = ('country', 'upload_date')
    search_fields = ('name', 'country__name')
    readonly_fields = ('upload_date',)
    fieldsets = (
        (None, {
            'fields': (
                'name',
                'country',
                'geographic_field_name',
                'csv_file',
                'upload_date',
            )
        }),
    )


@admin.register(OptScenario)
class OptScenarioAdmin(admin.ModelAdmin):
    list_display = ("name", "type_of_waste", "strategy", "geo_scenario", "upload_date")
    list_filter = ("type_of_waste", "strategy", "upload_date")
    search_fields = ("name",)
    readonly_fields = ("upload_date",)
    fieldsets = (
        (None, {
            "fields": ("name", "type_of_waste", "strategy", "geo_scenario")
        }),
        ("Archivos del escenario", {
            "fields": ("optimized_csv", "dispatch_json")
        }),
        ("Metadata", {
            "fields": ("upload_date",)
        }),
    )
