from django.contrib import admin
from .models import ComplaintCategory, Complaint, ComplaintStatusHistory

@admin.register(ComplaintCategory)
class ComplaintCategoryAdmin(admin.ModelAdmin):
    list_display = ('name', 'category_id','tenant', 'created_at')
    search_fields = ('name',)
    list_filter = ('tenant',)

@admin.register(Complaint)
class ComplaintAdmin(admin.ModelAdmin):
    list_display = ('short_description', 'tenant', 'status', 'timestamp',)
    list_filter = ('status', 'tenant', 'category')
    search_fields = ('short_description', 'complaint_text', )
    # This makes the user_hash field read-only in the admin, as it should be generated automatically
    readonly_fields = ('timestamp','user')

@admin.register(ComplaintStatusHistory)
class ComplaintStatusHistoryAdmin(admin.ModelAdmin):
    list_display = ('complaint', 'status', 'changed_at', 'changed_by','resolution_message')
    list_filter = ('status', 'changed_by')
    readonly_fields = ('changed_at',)
