diff --git a/services/presentation/app/config.py b/services/presentation/app/config.py index 753cdc2..440f32f 100644 --- a/services/presentation/app/config.py +++ b/services/presentation/app/config.py @@ -15,3 +15,17 @@ class Settings: settings = Settings() + +# Domyślna (wklepana) lokalizacja formularzy — miejsce urodzenia właściciela: +# Szpital Barlickiego w Łodzi, 51°46'26.1"N 19°28'58.6"E (potwierdzone reverse- +# geokodowaniem OSM: Kopcińskiego 22/28). QoL — nie trzeba wpisywać jej za każdym +# razem. Przycisk „Tu i teraz" nadal ją nadpisuje geolokalizacją przeglądarki. +# Można nadpisać zmiennymi środowiskowymi (np. inny współpracownik). +DEFAULT_LAT: float = float(os.getenv("DEFAULT_LAT", "51.7739")) +DEFAULT_LON: float = float(os.getenv("DEFAULT_LON", "19.4829")) +DEFAULT_LOCATION_LABEL: str = os.getenv("DEFAULT_LOCATION_LABEL", "Szpital Barlickiego, Łódź") + + +def default_form() -> dict: + """Wstępnie wypełnione pola lokalizacji na czystym formularzu (GET).""" + return {"lat": DEFAULT_LAT, "lon": DEFAULT_LON} diff --git a/services/presentation/app/main.py b/services/presentation/app/main.py index 6a3744b..78381cd 100644 --- a/services/presentation/app/main.py +++ b/services/presentation/app/main.py @@ -18,6 +18,7 @@ from fastapi.staticfiles import StaticFiles from fastapi.templating import Jinja2Templates from app.clients.logic_client import LogicClient +from app.config import DEFAULT_LOCATION_LABEL, default_form app = FastAPI(title="astrololo · warstwa prezentacji") app.mount("/static", StaticFiles(directory="app/static"), name="static") @@ -48,7 +49,10 @@ def _logic_error(e: Exception) -> str: # ---------------- Horoskop: pozycje (strona główna) ---------------- @app.get("/", response_class=HTMLResponse) def chart_form(request: Request): - return templates.TemplateResponse(request, "chart.html", {"result": None, "form": {}}) + return templates.TemplateResponse( + request, "chart.html", + {"result": None, "form": default_form(), "location_label": DEFAULT_LOCATION_LABEL}, + ) @app.post("/", response_class=HTMLResponse) @@ -105,7 +109,10 @@ def significators_search( # ---------------- Interpretacje (wynik obliczeń szukany w bazie) ---------------- @app.get("/interpret", response_class=HTMLResponse) def interpret_form(request: Request): - return templates.TemplateResponse(request, "interpret.html", {"result": None, "form": {}}) + return templates.TemplateResponse( + request, "interpret.html", + {"result": None, "form": default_form(), "location_label": DEFAULT_LOCATION_LABEL}, + ) @app.post("/interpret", response_class=HTMLResponse) @@ -135,7 +142,10 @@ def interpret_run( # ---------------- Kalendarz (oś czasu z technik + interpretacje) ---------------- @app.get("/timeline", response_class=HTMLResponse) def timeline_form(request: Request): - return templates.TemplateResponse(request, "timeline.html", {"result": None, "form": {}}) + return templates.TemplateResponse( + request, "timeline.html", + {"result": None, "form": default_form(), "location_label": DEFAULT_LOCATION_LABEL}, + ) @app.post("/timeline", response_class=HTMLResponse) diff --git a/services/presentation/app/templates/chart.html b/services/presentation/app/templates/chart.html index 7d1ae20..7539180 100644 --- a/services/presentation/app/templates/chart.html +++ b/services/presentation/app/templates/chart.html @@ -37,6 +37,7 @@ + {% if location_label %}
Wstępnie wpisano lokalizację: {{ location_label }} ({{ form.lat }}, {{ form.lon }}). Zmień pola lub kliknij „Tu i teraz".
{% endif %}Wstępnie wpisano lokalizację: {{ location_label }} ({{ form.lat }}, {{ form.lon }}). Zmień pola lub kliknij „Tu i teraz".
{% endif %}Wstępnie wpisano lokalizację: {{ location_label }} ({{ form.lat }}, {{ form.lon }}). Zmień pola lub kliknij „Tu i teraz".
{% endif %}