Skip to content

Commit 8ef05ee

Browse files
authored
feature: add main language env var in rules endpoint (#22)
1 parent aa24cd8 commit 8ef05ee

File tree

4 files changed

+7
-1
lines changed

4 files changed

+7
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ services:
6161
environment:
6262
- ROOMS=QGIS,Field and mobile,GIS tribe, Living room,Kitchen,Garden
6363
- RULES=Be kind and nice to this wonderful world
64+
- MAIN_LANGUAGE=en
6465
- MIN_AUTHOR_LENGTH=3
6566
- MAX_AUTHOR_LENGTH=32
6667
- MAX_MESSAGE_LENGTH=255

gischat/app.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,10 @@ async def get_rooms() -> list[str]:
128128

129129
@app.get("/rules", response_model=RulesModel)
130130
async def get_rules() -> RulesModel:
131-
return RulesModel(rules=os.environ.get("RULES", "YOLO"))
131+
return RulesModel(
132+
rules=os.environ.get("RULES", "YOLO"),
133+
main_lang=os.environ.get("MAIN_LANG", "en"),
134+
)
132135

133136

134137
@app.put(

gischat/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class StatusModel(BaseModel):
2121

2222
class RulesModel(BaseModel):
2323
rules: str
24+
main_lang: str
2425

2526

2627
class MessageModel(BaseModel):

tests/test_api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def test_get_rules(client: TestClient):
3737
response = client.get("/rules")
3838
assert response.status_code == 200
3939
assert response.json()["rules"] == TEST_RULES
40+
assert response.json()["main_lang"] == "en"
4041

4142

4243
@pytest.mark.parametrize("room", test_rooms())

0 commit comments

Comments
 (0)