from sqladmin import ModelView

from app.users.models import Users
from app.users.chat.models import Chats, UsersXChats, Messages


class UsersAdmin(ModelView, model=Users):
    column_list = [
        Users.id,
        Users.email,
        Users.username,
        Users.role,
        Users.black_phoenix,
        Users.avatar_image,
        Users.date_of_birth,
        Users.date_of_registration,
        Users.usersxchats,
    ]

    column_details_exclude_list = [Users.hashed_password]
    can_delete = False
    name = "Пользователь"
    name_plural = "Пользователи"
    icon = "fa-solid fa-users"


class ChatsAdmin(ModelView, model=Chats):
    column_list = [Chats.id, Chats.chat_for, Chats.usersxchats]
    name = "Чат"
    name_plural = "Чаты"
    icon = "fa-solid fa-comment"


class MessagesAdmin(ModelView, model=Messages):
    column_list = [
        Messages.id,
        Messages.chat_id,
        Messages.user_id,
        Messages.message,
        Messages.image_url,
        Messages.created_at,
        Messages.visibility,
        Messages.user,
    ]
    name = "Сообщение"
    name_plural = "Сообщения"
    icon = "fa-solid fa-sms"


class UsersXChatsAdmin(ModelView, model=UsersXChats):
    column_list = [UsersXChats.user_id, UsersXChats.chat_id]
    name = "Допущенный чат"
    name_plural = "Допущенные чаты"
    icon = "fa-solid fa-list"
