from django.contrib import admin
from .models import Event, Occurrence, EventAttribute


@admin.register(Event)
class EventAdmin(admin.ModelAdmin):
    list_display = ('name', 'event_type', 'parent', 'start_date', 'end_date', 'habitat')
    list_filter = ('event_type', 'start_date', 'habitat')
    search_fields = ('name', 'location_note', 'habitat', 'fieldNotes')
    readonly_fields = ('created_at', 'updated_at')
    ordering = ('start_date', 'name')


@admin.register(Occurrence)
class OccurrenceAdmin(admin.ModelAdmin):
    list_display = ('taxon_name', 'common_name', 'event', 'occurrence_date', 'recorded_by')
    list_filter = ('occurrence_date', 'created_at')
    search_fields = ('taxon_name', 'taxon_id', 'common_name', 'occurrence_id', 'recorded_by')
    readonly_fields = ('created_at', 'updated_at')
    ordering = ('occurrence_date', 'taxon_name')


@admin.register(EventAttribute)
class EventAttributeAdmin(admin.ModelAdmin):
    list_display = ('attribute_type', 'attribute_value', 'unit', 'event', 'occurrence')
    list_filter = ('attribute_type', 'created_at')
    search_fields = ('attribute_type', 'attribute_value')
    readonly_fields = ('created_at', 'updated_at')
    ordering = ('attribute_type', 'created_at')
