From 83ec86b027666df0131329b3e6f0f611d2641e32 Mon Sep 17 00:00:00 2001 From: matsewe Date: Mon, 26 May 2025 20:43:35 +0200 Subject: [PATCH] update --- app/main.py | 10 +++++++++- app/models.py | 6 +++++- app/templates/registration-closed.html | 2 +- app/templates/registration-not-open.html | 11 +++++++++++ 4 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 app/templates/registration-not-open.html diff --git a/app/main.py b/app/main.py index 3f00c7d..bfab842 100644 --- a/app/main.py +++ b/app/main.py @@ -26,17 +26,25 @@ templates = Jinja2Templates(directory="app/templates") @api_router.get("/") def index(request: Request): reg_open, not_before, not_after = is_registration_open() + print(reg_open, not_before, not_after) 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={ "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): diff --git a/app/models.py b/app/models.py index 5bad98d..32dc192 100644 --- a/app/models.py +++ b/app/models.py @@ -9,6 +9,9 @@ from datetime import date, datetime from sqlalchemy.sql import func +from app.core.config import settings +from datetime import datetime + class VoiceEnum(str, Enum): base = "Bass" @@ -42,4 +45,5 @@ 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)) + diff --git a/app/templates/registration-closed.html b/app/templates/registration-closed.html index 2f44c79..34930a5 100644 --- a/app/templates/registration-closed.html +++ b/app/templates/registration-closed.html @@ -5,7 +5,7 @@ - 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. \ No newline at end of file diff --git a/app/templates/registration-not-open.html b/app/templates/registration-not-open.html new file mode 100644 index 0000000..da400de --- /dev/null +++ b/app/templates/registration-not-open.html @@ -0,0 +1,11 @@ + + + + Choriosity Anmeldung + + + + 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') }}. + + + \ No newline at end of file