Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5b92bc8465 | |||
| 83ec86b027 | |||
| 726767c950 | |||
| 1a1179a9ee |
9
app/core/utils.py
Normal file
9
app/core/utils.py
Normal 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
|
||||||
10
app/main.py
10
app/main.py
@@ -26,17 +26,25 @@ 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()
|
||||||
|
print(reg_open, not_before, not_after)
|
||||||
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):
|
||||||
|
|||||||
@@ -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,5 @@ 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
11
app/templates/registration-closed.html
Normal file
11
app/templates/registration-closed.html
Normal 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>
|
||||||
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>
|
||||||
81
app/templates/registration-open.html
Normal file
81
app/templates/registration-open.html
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
<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" /><br />
|
||||||
|
<label for="first_name">Dein Vorname:</label> <input type="text" id="first_name" name="first_name" /><br />
|
||||||
|
<label for="last_name">Dein Nachname:</label> <input type="text" id="last_name" name="last_name" /><br />
|
||||||
|
<label for="age">Dein Alter:</label> <input type="number" id="age" name="age" /><br />
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<legend>Welche Stimme singst du?</legend>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<input type="radio" id="base" name="voice" value="Bass" />
|
||||||
|
<label for="base">Bass</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<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" /><br />
|
||||||
|
|
||||||
|
<input type="submit" value="Anmelden" />
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
11
app/templates/registration-success.html
Normal file
11
app/templates/registration-success.html
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Choriosity Anmeldung</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
Danke für deine Anmeldung
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user