from sqladmin import ModelView

from app.song.models import Song


class SongAdmin(ModelView, model=Song):
    name = "노래"
    name_plural = "노래 목록"
    icon = "fa-solid fa-headphones"
    category = "노래 관리"
    page_size = 20

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

    column_details_list = [
        "id",
        "project_id",
        "lyric_id",
        "task_id",
        "suno_task_id",
        "status",
        "language",
        "song_prompt",
        "song_result_url",
        "created_at",
    ]

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

    column_searchable_list = [
        Song.task_id,
        Song.suno_task_id,
        Song.status,
        Song.language,
    ]

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

    column_sortable_list = [
        Song.id,
        Song.project_id,
        Song.lyric_id,
        Song.status,
        Song.language,
        Song.created_at,
    ]

    column_labels = {
        "id": "ID",
        "project_id": "프로젝트 ID",
        "lyric_id": "가사 ID",
        "task_id": "작업 ID",
        "suno_task_id": "Suno 작업 ID",
        "status": "상태",
        "language": "언어",
        "song_prompt": "프롬프트",
        "song_result_url": "결과 URL",
        "created_at": "생성일시",
    }
