from django.contrib import admin
from .models import RSVP, Accreditation

@admin.register(RSVP)
class RSVPAdmin(admin.ModelAdmin):
    list_display = ('first_name', 'last_name', 'email', 'phone', 'created_at', 'is_sent')
    list_filter = ('created_at', 'is_sent')
    search_fields = ('first_name', 'last_name', 'email', 'phone')
    list_editable = ('email', 'phone', 'is_sent')
    list_per_page = 20

@admin.register(Accreditation)
class AccreditationAdmin(admin.ModelAdmin):
    list_display = ('rsvp__name', 'date', 'time', 'is_accredited_display')
    list_filter = ('date', 'is_accredited')
    search_fields = ('rsvp__first_name', 'rsvp__last_name')
    list_select_related = ('rsvp',)
    list_per_page = 20

    def is_accredited_display(self, obj):
        return obj.is_accredited
    is_accredited_display.short_description = 'Accredited'
    is_accredited_display.boolean = True