Compare commits
4 Commits
1a1179a9ee
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 394512f6eb | |||
| 5b92bc8465 | |||
| 83ec86b027 | |||
| 726767c950 |
31
app/main.py
31
app/main.py
@@ -1,8 +1,6 @@
|
|||||||
from fastapi import FastAPI, Request
|
from fastapi import FastAPI, Request
|
||||||
from fastapi.staticfiles import StaticFiles
|
from fastapi.staticfiles import StaticFiles
|
||||||
|
|
||||||
from fastapi.responses import FileResponse
|
|
||||||
|
|
||||||
from fastapi.templating import Jinja2Templates
|
from fastapi.templating import Jinja2Templates
|
||||||
|
|
||||||
from app.api.main import api_router
|
from app.api.main import api_router
|
||||||
@@ -23,32 +21,47 @@ app = FastAPI(
|
|||||||
|
|
||||||
templates = Jinja2Templates(directory="app/templates")
|
templates = Jinja2Templates(directory="app/templates")
|
||||||
|
|
||||||
|
|
||||||
@api_router.get("/")
|
@api_router.get("/")
|
||||||
def index(request: Request):
|
def index(request: Request):
|
||||||
reg_open, not_before, not_after = is_registration_open()
|
reg_open, not_before, not_after = is_registration_open()
|
||||||
|
|
||||||
if reg_open:
|
if reg_open:
|
||||||
return templates.TemplateResponse(
|
return templates.TemplateResponse(
|
||||||
request=request, name="registration-open.html", context={}
|
request=request, name="registration-open.html", context={}
|
||||||
)
|
)
|
||||||
else:
|
elif not_before:
|
||||||
return templates.TemplateResponse(
|
return templates.TemplateResponse(
|
||||||
request=request, name="registration-closed.html", context={
|
request=request,
|
||||||
|
name="registration-closed.html",
|
||||||
|
context={
|
||||||
"not_before": settings.NOT_BEFORE,
|
"not_before": settings.NOT_BEFORE,
|
||||||
"not_after": settings.NOT_AFTER,
|
"not_after": settings.NOT_AFTER,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
|
elif not_after:
|
||||||
|
return templates.TemplateResponse(
|
||||||
|
request=request,
|
||||||
|
name="registration-not-open.html",
|
||||||
|
context={
|
||||||
|
"not_before": settings.NOT_BEFORE,
|
||||||
|
"not_after": settings.NOT_AFTER,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@api_router.get("/success.html")
|
@api_router.get("/success.html")
|
||||||
def success(request: Request):
|
def success(request: Request):
|
||||||
return templates.TemplateResponse(
|
return templates.TemplateResponse(
|
||||||
request=request, name="registration-success.html", context={
|
request=request,
|
||||||
|
name="registration-success.html",
|
||||||
|
context={
|
||||||
"not_before": settings.NOT_BEFORE,
|
"not_before": settings.NOT_BEFORE,
|
||||||
"not_after": settings.NOT_AFTER,
|
"not_after": settings.NOT_AFTER,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
app.include_router(api_router, prefix=settings.API_V1_STR)
|
app.include_router(api_router, prefix=settings.API_V1_STR)
|
||||||
|
|
||||||
app.mount("/static", StaticFiles(directory="app/static"), name="static")
|
app.mount("/static", StaticFiles(directory="app/static"), name="static")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,9 @@ from pydantic import EmailStr
|
|||||||
from sqlmodel import Field, SQLModel
|
from sqlmodel import Field, SQLModel
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
from datetime import date, datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
from app.core.config import settings
|
||||||
from sqlalchemy.sql import func
|
|
||||||
|
|
||||||
|
|
||||||
class VoiceEnum(str, Enum):
|
class VoiceEnum(str, Enum):
|
||||||
@@ -30,7 +29,7 @@ class RegistrationBase(SQLModel):
|
|||||||
email: EmailStr = Field(max_length=255)
|
email: EmailStr = Field(max_length=255)
|
||||||
first_name: str
|
first_name: str
|
||||||
last_name: str
|
last_name: str
|
||||||
birthday: date
|
age: int
|
||||||
voice: VoiceEnum
|
voice: VoiceEnum
|
||||||
duration: PeriodEnum
|
duration: PeriodEnum
|
||||||
number_of_attempts: int
|
number_of_attempts: int
|
||||||
@@ -42,4 +41,4 @@ class RegistrationCreate(RegistrationBase):
|
|||||||
|
|
||||||
class Registration(RegistrationBase, table=True):
|
class Registration(RegistrationBase, table=True):
|
||||||
id: uuid.UUID = Field(default_factory=uuid.uuid4, primary_key=True)
|
id: uuid.UUID = Field(default_factory=uuid.uuid4, primary_key=True)
|
||||||
timestamp: datetime = Field(default_factory=func.now)
|
timestamp: datetime = Field(default_factory=lambda: datetime.now(tz=settings.TZ))
|
||||||
|
|||||||
0
app/static/styles.css
Normal file
0
app/static/styles.css
Normal file
@@ -5,7 +5,7 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
Die Anmeldung ist leider noch nicht geöffnet. Sie öffnet am {{ not_before }} und schließt am {{ not_after }}.
|
Die Anmeldung ist leider bereits geschlossen. Folge uns, um vom nächsten Anmeldezeitraum zu erfahren.
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
11
app/templates/registration-not-open.html
Normal file
11
app/templates/registration-not-open.html
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Choriosity Anmeldung</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
Die Anmeldung ist noch nicht geöffnet. Sie öffnet {{ not_before.strftime('am %d.%m.%Y um %H:%M Uhr') }} und schließt {{ not_after.strftime('am %d.%m.%Y um %H:%M Uhr') }}.
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -8,70 +8,30 @@
|
|||||||
<form method="POST" action="/registration/register_form">
|
<form method="POST" action="/registration/register_form">
|
||||||
|
|
||||||
|
|
||||||
<label for="email">E-Mail-Adresse:</label> <input type="email" id="email" name="email" />
|
<label for="email">Deine E-Mail-Adresse:</label> <input type="email" id="email" name="email" required /><br />
|
||||||
<label for="first_name">Dein Vorname:</label> <input type="text" id="first_name" name="first_name" />
|
<label for="first_name">Dein Vorname:</label> <input type="text" id="first_name" name="first_name" required /><br />
|
||||||
<label for="last_name">Dein Nachname:</label> <input type="text" id="last_name" name="last_name" />
|
<label for="last_name">Dein Nachname:</label> <input type="text" id="last_name" name="last_name" required /><br />
|
||||||
<label for="birthday">Dein Geburtstag:</label> <input type="date" id="birthday" name="birthday" />
|
<label for="age">Dein Alter:</label> <input type="number" id="age" name="age" min="1" max="199" step="1" required /><br />
|
||||||
|
|
||||||
<fieldset>
|
<label for="voice">Wie lange bleibst du in Ulm?</label>
|
||||||
<legend>Welche Stimme singst du?</legend>
|
<select name="voice" id="voice">
|
||||||
|
<option value="Bass">Bass</option>
|
||||||
|
<option value="Tenor">Tenor</option>
|
||||||
|
<option value="Alt">Alt</option>
|
||||||
|
<option value="Sopran">Sopran</option>
|
||||||
|
<option value="Alt oder Sopran">Alt oder Sopran</option>
|
||||||
|
<option value="Bass oder Tenor">Bass oder Tenor</option>
|
||||||
|
</select><br />
|
||||||
|
|
||||||
<div>
|
<label for="duration">Wie lange bleibst du in Ulm?</label>
|
||||||
<input type="radio" id="base" name="voice" value="Bass" />
|
<select name="duration" id="duration">
|
||||||
<label for="base">Bass</label>
|
<option value="1/2 Jahr">1/2 Jahr</option>
|
||||||
</div>
|
<option value="1/2 - 1 Jahr">1/2 - 1 Jahr</option>
|
||||||
|
<option value="1 - 2 Jahre">1 - 2 Jahre</option>
|
||||||
|
<option value="mehr als zwei Jahre">länger als 2 Jahre</option>
|
||||||
|
</select> <br />
|
||||||
|
|
||||||
<div>
|
<label for="number_of_attempts">Wie oft hast du schon versucht, dich anzumelden?</label><input type="number" id="number_of_attempts" name="number_of_attempts" min="0" max="10" value="0" required /><br />
|
||||||
<input type="radio" id="tenor" name="voice" value="Tenor" />
|
|
||||||
<label for="tenor">Tenor</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<input type="radio" id="alto" name="voice" value="Alt" />
|
|
||||||
<label for="alto">Alt</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<input type="radio" id="soprano" name="voice" value="Sopran" />
|
|
||||||
<label for="soprano">Sopran</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<input type="radio" id="women" name="voice" value="Alt oder Sopran" />
|
|
||||||
<label for="women">Sopran oder Alt</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<input type="radio" id="men" name="voice" value="Bass oder Tenor" />
|
|
||||||
<label for="men">Bass oder Tenor</label>
|
|
||||||
</div>
|
|
||||||
</fieldset>
|
|
||||||
|
|
||||||
<fieldset>
|
|
||||||
<legend>Wie lange bleibst du in Ulm?</legend>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<input type="radio" id="halfyear" name="duration" value="1/2 Jahr" />
|
|
||||||
<label for="halfyear">1/2 Jahr</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<input type="radio" id="halfyear" name="duration" value="1/2 - 1 Jahr" />
|
|
||||||
<label for="halfyear">1/2 - 1 Jahr</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<input type="radio" id="twoyears" name="duration" value="1 - 2 Jahre" />
|
|
||||||
<label for="twoyears">1 - 2 jahre</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<input type="radio" id="longterm" name="duration" value="mehr als zwei Jahre" />
|
|
||||||
<label for="longterm">länger als 2 Jahre</label>
|
|
||||||
</div>
|
|
||||||
</fieldset>
|
|
||||||
|
|
||||||
<label for="number_of_attempts">Wie oft hast du schon versucht, dich anzumelden?</label><input type="number" id="number_of_attempts" name="number_of_attempts" />
|
|
||||||
|
|
||||||
<input type="submit" value="Anmelden" />
|
<input type="submit" value="Anmelden" />
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user