from django.contrib import admin
from simple_history.admin import SimpleHistoryAdmin
from .models import Well, WaterMeterManufacturer

# Register your models here.

@admin.register(WaterMeterManufacturer)
class WaterMeterManufacturerAdmin(admin.ModelAdmin):
    list_display = ['name']
    search_fields = ['name']
    ordering = ['name']

@admin.register(Well)
class WellAdmin(SimpleHistoryAdmin):
    list_display = ['water_subscription_number', 'representative', 'electricity_subscription_number', 'water_meter_manufacturer', 'county']
    list_filter = ['representative', 'water_meter_manufacturer', 'county', 'broker']
    search_fields = [
        'water_subscription_number', 
        'electricity_subscription_number',
        'representative__username', 
        'representative__first_name', 
        'representative__last_name'
    ]
    autocomplete_fields = ['representative', 'water_meter_manufacturer', 'affairs', 'county', 'broker']
    
    history_list_display = ['water_subscription_number', 'representative']
