diff --git a/.env.example b/.env.example index e4a89fa..eb2ded8 100644 --- a/.env.example +++ b/.env.example @@ -20,6 +20,10 @@ CLIENT_HOST=0.0.0.0 CLIENT_PORT=5000 CLIENT_SECRET_KEY=change-this-to-another-random-secret-key API_SERVER_URL=http://localhost:8000 +# Station code this client container belongs to (e.g. ST-001). +# Each physical tablet/PC deployment must set this unique per-station value. +# Leave empty only for a single-station all-in-one demo using ST-DEFAULT. +STATION_CODE=ST-DEFAULT # --- File Storage --- UPLOAD_DIR=server/uploads diff --git a/client/config.py b/client/config.py index 51bd2f2..3a3ee54 100644 --- a/client/config.py +++ b/client/config.py @@ -22,6 +22,10 @@ class Config: PERMANENT_SESSION_LIFETIME = 28800 # 8 hours WTF_CSRF_TIME_LIMIT = 3600 # 1 hour + # Station identity: each deployed client container sets this to the station + # code it belongs to. Empty/None means "not configured". + STATION_CODE: str | None = os.getenv("STATION_CODE") or None + # Babel i18n BABEL_DEFAULT_LOCALE = "it" BABEL_DEFAULT_TIMEZONE = "Europe/Rome" diff --git a/client/tests/test_config_station.py b/client/tests/test_config_station.py new file mode 100644 index 0000000..96bb825 --- /dev/null +++ b/client/tests/test_config_station.py @@ -0,0 +1,17 @@ +"""Tests that STATION_CODE is loaded from env and exposed on the client Config class.""" +import importlib +import os + + +def test_station_code_read_from_env(monkeypatch): + monkeypatch.setenv("STATION_CODE", "ST-TEST") + import config + importlib.reload(config) + assert config.Config.STATION_CODE == "ST-TEST" + + +def test_station_code_defaults_to_none_when_missing(monkeypatch): + monkeypatch.delenv("STATION_CODE", raising=False) + import config + importlib.reload(config) + assert config.Config.STATION_CODE is None