5 Commits
v0.2 ... master

Author SHA1 Message Date
394512f6eb update form 2025-05-27 10:56:48 +02:00
5b92bc8465 Ask for age instead of birth date
All checks were successful
release-tag / release-image (push) Successful in 36s
2025-05-26 20:48:47 +02:00
83ec86b027 update 2025-05-26 20:43:35 +02:00
726767c950 fix? hopefully ..
All checks were successful
release-tag / release-image (push) Successful in 33s
2025-05-26 11:02:21 +02:00
1a1179a9ee fix broken commit
All checks were successful
release-tag / release-image (push) Successful in 32s
2025-05-26 10:58:36 +02:00
8 changed files with 115 additions and 20 deletions

9
app/core/utils.py Normal file
View File

@@ -0,0 +1,9 @@
from app.core.config import settings
from datetime import datetime
def is_registration_open():
now = datetime.now(tz=settings.TZ)
not_before = now >= settings.NOT_BEFORE
not_after = now <= settings.NOT_AFTER
return not_before and not_after, not_before, not_after

View File

@@ -1,8 +1,6 @@
from fastapi import FastAPI, Request
from fastapi.staticfiles import StaticFiles
from fastapi.responses import FileResponse
from fastapi.templating import Jinja2Templates
from app.api.main import api_router
@@ -23,32 +21,47 @@ app = FastAPI(
templates = Jinja2Templates(directory="app/templates")
@api_router.get("/")
def index(request: Request):
reg_open, not_before, not_after = is_registration_open()
if reg_open:
return templates.TemplateResponse(
request=request, name="registration-open.html", context={}
)
else:
elif not_before:
return templates.TemplateResponse(
request=request, name="registration-closed.html", context={
request=request,
name="registration-closed.html",
context={
"not_before": settings.NOT_BEFORE,
"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")
def success(request: Request):
return templates.TemplateResponse(
request=request, name="registration-success.html", context={
request=request,
name="registration-success.html",
context={
"not_before": settings.NOT_BEFORE,
"not_after": settings.NOT_AFTER,
}
},
)
app.include_router(api_router, prefix=settings.API_V1_STR)
app.mount("/static", StaticFiles(directory="app/static"), name="static")

View File

@@ -4,10 +4,9 @@ from pydantic import EmailStr
from sqlmodel import Field, SQLModel
from enum import Enum
from datetime import date, datetime
from datetime import datetime
from sqlalchemy.sql import func
from app.core.config import settings
class VoiceEnum(str, Enum):
@@ -30,7 +29,7 @@ class RegistrationBase(SQLModel):
email: EmailStr = Field(max_length=255)
first_name: str
last_name: str
birthday: date
age: int
voice: VoiceEnum
duration: PeriodEnum
number_of_attempts: int
@@ -42,4 +41,4 @@ class RegistrationCreate(RegistrationBase):
class Registration(RegistrationBase, table=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
View File

View File

@@ -0,0 +1,11 @@
<html>
<head>
<title>Choriosity Anmeldung</title>
</head>
<body>
Die Anmeldung ist leider bereits geschlossen. Folge uns, um vom nächsten Anmeldezeitraum zu erfahren.
</body>
</html>

View 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>

View File

@@ -0,0 +1,41 @@
<html>
<head>
<title>Choriosity Anmeldung</title>
</head>
<body>
<form method="POST" action="/registration/register_form">
<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" required /><br />
<label for="last_name">Dein Nachname:</label> <input type="text" id="last_name" name="last_name" required /><br />
<label for="age">Dein Alter:</label> <input type="number" id="age" name="age" min="1" max="199" step="1" required /><br />
<label for="voice">Wie lange bleibst du in Ulm?</label>
<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 />
<label for="duration">Wie lange bleibst du in Ulm?</label>
<select name="duration" id="duration">
<option value="1/2 Jahr">1/2 Jahr</option>
<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 />
<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="submit" value="Anmelden" />
</form>
</body>
</html>

View File

@@ -0,0 +1,11 @@
<html>
<head>
<title>Choriosity Anmeldung</title>
</head>
<body>
Danke für deine Anmeldung
</body>
</html>