-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #395 from open-contracting/362-translate-more-enums
feat: add meta endpoint
- Loading branch information
Showing
6 changed files
with
83 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
from . import applications, emails # noqa: F401 | ||
from . import applications, emails, meta # noqa: F401 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from fastapi import APIRouter | ||
|
||
from app import models | ||
from app.i18n import _ | ||
|
||
router = APIRouter() | ||
|
||
|
||
@router.get( | ||
"/meta", | ||
tags=["meta"], | ||
) | ||
async def get_settings_by_domain() -> dict[str, list[dict[str, str]]]: | ||
""" | ||
Get the keys and localized descriptions of constants, where a constant can be: | ||
- BorrowerDocumentType | ||
- BorrowerSector | ||
- BorrowerSize | ||
- BorrowerType | ||
:return: A dict of constants with their keys and localized values. | ||
""" | ||
constants = {} | ||
for domain in ( | ||
"BorrowerDocumentType", | ||
"BorrowerSector", | ||
"BorrowerSize", | ||
"BorrowerType", | ||
): | ||
constants[domain] = [{"label": _(name), "value": name} for name in getattr(models, domain)] | ||
return constants |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters