from django.contrib import admin
from .models import Photo, Album, Category

@admin.register(Category)
class CategoryAdmin(admin.ModelAdmin):
    list_display = ['name', 'created_at']
    search_fields = ['name']

@admin.register(Album)
class AlbumAdmin(admin.ModelAdmin):
    list_display = ['title', 'created_by', 'photo_count', 'created_at']
    list_filter = ['created_by', 'created_at']
    search_fields = ['title', 'description']
    readonly_fields = ['created_at', 'updated_at']
    # filter_horizontal = ['photos']  <-- remove this line


@admin.register(Photo)
class PhotoAdmin(admin.ModelAdmin):
    list_display = ['title', 'category', 'is_favorite', 'uploaded_at', 'width', 'height']
    list_filter = ['is_favorite', 'category', 'uploaded_at', 'albums']
    search_fields = ['title']
    readonly_fields = ['thumbnail', 'width', 'height', 'uploaded_at']
    filter_horizontal = ['albums']   # correct now
