from django.contrib import admin
from .models import Message

class MessageInline(admin.TabularInline):
    model = Message
    extra = 0
    readonly_fields = ('timestamp',)
    fields = ('sender', 'content', 'message_type', 'timestamp')
    show_change_link = True

@admin.register(Message)
class MessageAdmin(admin.ModelAdmin):
    list_display = ('id', 'ticket', 'sender', 'message_type', 'timestamp')
    list_filter = ('message_type', 'sender')
    search_fields = ('content', 'ticket__title', 'sender__username')
    ordering = ('timestamp',)
    readonly_fields = ('timestamp',)
