from django.contrib import admin
from .models import BlogCategory, Tag, BlogPost

@admin.register(BlogCategory)
class BlogCategoryAdmin(admin.ModelAdmin):
    list_display = ('name', 'slug')
    prepopulated_fields = {'slug': ('name',)}

@admin.register(Tag)
class TagAdmin(admin.ModelAdmin):
    list_display = ('name', 'slug')
    prepopulated_fields = {'slug': ('name',)}

@admin.register(BlogPost)
class BlogPostAdmin(admin.ModelAdmin):
    list_display = ('title', 'category', 'author_name', 'status', 'published_at', 'views_count', 'is_featured')
    list_editable = ('status', 'is_featured')
    list_filter = ('status', 'category', 'is_featured', 'published_at')
    search_fields = ('title', 'summary', 'content', 'author_name')
    filter_horizontal = ('tags',)
    prepopulated_fields = {'slug': ('title',)}
