33 lines
755 B
Python
33 lines
755 B
Python
from typing import Annotated
|
|
|
|
from fastapi import APIRouter, Form
|
|
from app.models import RegistrationCreate
|
|
from app import crud
|
|
from app.api.deps import SessionDep
|
|
|
|
from app.core.utils import is_registration_open
|
|
|
|
from fastapi.responses import RedirectResponse
|
|
|
|
router = APIRouter(prefix="/registration")
|
|
|
|
|
|
@router.post(
|
|
"/register_form",
|
|
)
|
|
def register(
|
|
*, session: SessionDep, registration_create: Annotated[RegistrationCreate, Form()]
|
|
):
|
|
"""
|
|
Register
|
|
"""
|
|
|
|
if is_registration_open():
|
|
crud.create_registration(
|
|
session=session, registration_create=registration_create
|
|
)
|
|
|
|
return RedirectResponse("/success.html", status_code=303)
|
|
else:
|
|
return RedirectResponse("/", status_code=303)
|