from django.contrib import admin

from vbv_lernwelt.media_files.models import UserDocument, UserImage


@admin.register(UserDocument)
class UserDocumentAdmin(admin.ModelAdmin):
    list_display = (
        "title",
        "file",
        "created_at",
        "uploaded_by_user",
        "file_size",
        "file_hash",
    )
    search_fields = ("title", "uploaded_by_user__username", "tags__name")
    list_filter = ("created_at", "uploaded_by_user")
    autocomplete_fields = ["uploaded_by_user"]
    date_hierarchy = "created_at"
    readonly_fields = (
        "file_size",
        "file_hash",
        "created_at",
        "uploaded_by_user",
        "file",
    )


@admin.register(UserImage)
class UserImageAdmin(admin.ModelAdmin):
    list_display = (
        "title",
        "file",
        "created_at",
        "uploaded_by_user",
        "file_size",
    )
    search_fields = ("title", "uploaded_by_user__username")
    list_filter = ("created_at", "uploaded_by_user")
    autocomplete_fields = ["uploaded_by_user"]
    date_hierarchy = "created_at"
    readonly_fields = (
        "file_size",
        "file_hash",
        "created_at",
        "uploaded_by_user",
        "file",
        "tags",
        "title",
        "focal_point_x",
        "focal_point_y",
        "focal_point_width",
        "focal_point_height",
    )
