from django.contrib import admin
from .models import PublicBody, Party, Member, Question, Answer, Vote


@admin.register(PublicBody)
class PublicBodyAdmin(admin.ModelAdmin):
    list_display = ("name", "website")
    prepopulated_fields = {"slug": ("name",)}
    search_fields = ("name",)


@admin.register(Party)
class PartyAdmin(admin.ModelAdmin):
    list_display = ("name", "abbreviation")
    search_fields = ("name", "abbreviation")


@admin.register(Member)
class MemberAdmin(admin.ModelAdmin):
    list_display = ("first_name", "last_name", "public_body", "party")
    list_filter = ("public_body", "party")
    search_fields = ("first_name", "last_name")


@admin.register(Question)
class QuestionAdmin(admin.ModelAdmin):
    list_display = ("title", "member", "created_at")
    list_filter = ("member",)
    search_fields = ("title", "body")


@admin.register(Answer)
class AnswerAdmin(admin.ModelAdmin):
    list_display = ("question", "answered_by", "created_at")
    list_filter = ("answered_by",)
    search_fields = ("body",)


@admin.register(Vote)
class VoteAdmin(admin.ModelAdmin):
    list_display = ("title", "public_body", "date")
    list_filter = ("public_body", "date")
    search_fields = ("title", "description") 