from django.contrib import admin

from .models import BlogPost, Bug, Friendship, Message


@admin.register(Message)
class MessageAdmin(admin.ModelAdmin):
    list_display  = ('sender', 'recipient', 'subject', 'sent_at', 'read_at')
    list_filter   = ('sent_at',)
    search_fields = ('sender__email', 'recipient__email', 'subject')
    readonly_fields = ('sent_at', 'read_at')


@admin.register(BlogPost)
class BlogPostAdmin(admin.ModelAdmin):
    list_display  = ('author', 'title', 'is_public', 'created_at')
    list_filter   = ('is_public',)
    search_fields = ('author__email', 'title')


@admin.register(Bug)
class BugAdmin(admin.ModelAdmin):
    list_display  = ('reporter', 'title', 'severity', 'status', 'created_at')
    list_filter   = ('severity', 'status')
    search_fields = ('reporter__email', 'title')
    readonly_fields = ('created_at', 'updated_at', 'resolved_at')


@admin.register(Friendship)
class FriendshipAdmin(admin.ModelAdmin):
    list_display  = ('from_user', 'to_user', 'status', 'created_at')
    list_filter   = ('status',)
    search_fields = ('from_user__email', 'to_user__email')
