from django.contrib import admin
from .models import Voter, VotingRecord, Donation, VoterContact, EventParticipation

class VotingRecordInline(admin.TabularInline):
    model = VotingRecord
    extra = 1

class DonationInline(admin.TabularInline):
    model = Donation
    extra = 1

class VoterContactInline(admin.TabularInline):
    model = VoterContact
    extra = 1

class EventParticipationInline(admin.TabularInline):
    model = EventParticipation
    extra = 1

@admin.register(Voter)
class VoterAdmin(admin.ModelAdmin):
    list_display = ('voter_id', 'last_name', 'first_name', 'district', 'precinct', 'candidate_support')
    list_filter = ('candidate_support', 'yard_sign_status', 'district')
    search_fields = ('voter_id', 'last_name', 'first_name', 'email')
    inlines = [VotingRecordInline, DonationInline, VoterContactInline, EventParticipationInline]

@admin.register(VotingRecord)
class VotingRecordAdmin(admin.ModelAdmin):
    list_display = ('voter', 'election_date', 'description')

@admin.register(Donation)
class DonationAdmin(admin.ModelAdmin):
    list_display = ('voter', 'donation_date', 'amount')

@admin.register(VoterContact)
class VoterContactAdmin(admin.ModelAdmin):
    list_display = ('voter', 'contact_type', 'contact_date')

@admin.register(EventParticipation)
class EventParticipationAdmin(admin.ModelAdmin):
    list_display = ('voter', 'event_type', 'event_date')