Skip to content

Commit

Permalink
feature: add main language env var in rules endpoint (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
gounux authored Jul 25, 2024
1 parent aa24cd8 commit 8ef05ee
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ services:
environment:
- ROOMS=QGIS,Field and mobile,GIS tribe, Living room,Kitchen,Garden
- RULES=Be kind and nice to this wonderful world
- MAIN_LANGUAGE=en
- MIN_AUTHOR_LENGTH=3
- MAX_AUTHOR_LENGTH=32
- MAX_MESSAGE_LENGTH=255
Expand Down
5 changes: 4 additions & 1 deletion gischat/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ async def get_rooms() -> list[str]:

@app.get("/rules", response_model=RulesModel)
async def get_rules() -> RulesModel:
return RulesModel(rules=os.environ.get("RULES", "YOLO"))
return RulesModel(
rules=os.environ.get("RULES", "YOLO"),
main_lang=os.environ.get("MAIN_LANG", "en"),
)


@app.put(
Expand Down
1 change: 1 addition & 0 deletions gischat/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class StatusModel(BaseModel):

class RulesModel(BaseModel):
rules: str
main_lang: str


class MessageModel(BaseModel):
Expand Down
1 change: 1 addition & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def test_get_rules(client: TestClient):
response = client.get("/rules")
assert response.status_code == 200
assert response.json()["rules"] == TEST_RULES
assert response.json()["main_lang"] == "en"


@pytest.mark.parametrize("room", test_rooms())
Expand Down

0 comments on commit 8ef05ee

Please sign in to comment.