from django.contrib import admin
from .models import Crop, Variety, Plan


@admin.register(Crop)
class CropAdmin(admin.ModelAdmin):
    list_display = ('name',)
    search_fields = ('name',)


@admin.register(Variety)
class VarietyAdmin(admin.ModelAdmin):
    list_display = ('crop', 'name')
    search_fields = ('name', 'crop__name')
    list_filter = ('crop',)


@admin.register(Plan)
class PlanAdmin(admin.ModelAdmin):
    list_display = ('field', 'year', 'crop', 'variety', 'notes')
    search_fields = ('field__name', 'crop__name', 'variety__name')
    list_filter = ('year', 'crop')
    ordering = ('-year', 'field')
