from django.core.handlers.wsgi import WSGIRequest
from django.http import HttpResponse

from config import ALLOW_NEW_USERS

from .helper import render_template


def index(request: WSGIRequest) -> HttpResponse:
    return render_template(
        request, "noauth/index.html",
        new_users=ALLOW_NEW_USERS
    )

def signup(request: WSGIRequest) -> HttpResponse:
    if ALLOW_NEW_USERS:
        return render_template(
            request, "noauth/signup.html",
            title="Sign Up"
        )

    return render_template(
        request, "404.html"
    )

def login(request: WSGIRequest) -> HttpResponse:
    return render_template(
        request, "noauth/login.html",
        title="Log In"
    )
