from sqladmin import ModelView

from app.video.models import Video


class VideoAdmin(ModelView, model=Video):
    name = "영상"
    name_plural = "영상 목록"
    icon = "fa-solid fa-video"
    category = "영상 관리"
    page_size = 20

    column_list = [
        "id",
        "project_id",
        "lyric_id",
        "song_id",
        "task_id",
        "status",
        "created_at",
    ]

    column_details_list = [
        "id",
        "project_id",
        "lyric_id",
        "song_id",
        "task_id",
        "status",
        "result_movie_url",
        "created_at",
    ]

    # 폼(생성/수정)에서 제외
    form_excluded_columns = ["created_at"]

    column_searchable_list = [
        Video.task_id,
        Video.status,
    ]

    column_default_sort = (Video.created_at, True)  # True: DESC (최신순)

    column_sortable_list = [
        Video.id,
        Video.project_id,
        Video.lyric_id,
        Video.song_id,
        Video.status,
        Video.created_at,
    ]

    column_labels = {
        "id": "ID",
        "project_id": "프로젝트 ID",
        "lyric_id": "가사 ID",
        "song_id": "노래 ID",
        "task_id": "작업 ID",
        "status": "상태",
        "result_movie_url": "영상 URL",
        "created_at": "생성일시",
    }
