from django.contrib.auth.mixins import LoginRequiredMixin

from core.forms import SessionForm
from core.models import ChatSession
from core.util import logs
from mixins.views import ObjectCreate, ObjectDelete, ObjectList, ObjectUpdate

log = logs.get_logger(__name__)


class SessionList(LoginRequiredMixin, ObjectList):
    list_template = "partials/session-list.html"
    model = ChatSession
    page_title = "Chat Sessions"
    # page_subtitle = "Add times here in order to permit trading."

    list_url_name = "sessions"
    list_url_args = ["type"]

    submit_url_name = "session_create"


class SessionCreate(LoginRequiredMixin, ObjectCreate):
    model = ChatSession
    form_class = SessionForm

    submit_url_name = "session_create"


class SessionUpdate(LoginRequiredMixin, ObjectUpdate):
    model = ChatSession
    form_class = SessionForm

    submit_url_name = "session_update"


class SessionDelete(LoginRequiredMixin, ObjectDelete):
    model = ChatSession
