feat(organization): scalar corporation_scope and scopes dictionary endpoint
This commit is contained in:
@@ -16,6 +16,21 @@ SCOPE_LABELS: dict[str, str] = {
|
||||
"rosatom": "Госкорпорация «Росатом»",
|
||||
"roscosmos": "Госкорпорация «Роскосмос»",
|
||||
"opk": "Организации ОПК",
|
||||
"other": "Иная корпорация",
|
||||
}
|
||||
|
||||
SCOPE_SHORT_NAMES: dict[str, str] = {
|
||||
"rosatom": "Росатом",
|
||||
"roscosmos": "Роскосмос",
|
||||
"opk": "ОПК",
|
||||
"other": "Иная",
|
||||
}
|
||||
|
||||
SCOPE_SORT_ORDER: dict[str, int] = {
|
||||
"rosatom": 10,
|
||||
"roscosmos": 20,
|
||||
"opk": 30,
|
||||
"other": 90,
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +53,27 @@ def scope_labels(scope_codes: Iterable[str]) -> list[str]:
|
||||
return [SCOPE_LABELS[code] for code in scope_codes if code in SCOPE_LABELS]
|
||||
|
||||
|
||||
def get_corporation_scope_dictionary() -> list[dict[str, str | int]]:
|
||||
"""Возвращает справочник корпусов для API-словаря."""
|
||||
items: list[dict[str, str | int]] = []
|
||||
for code, sort_order in sorted(
|
||||
SCOPE_SORT_ORDER.items(), key=lambda item: item[1]
|
||||
):
|
||||
label = SCOPE_LABELS.get(code)
|
||||
short_name = SCOPE_SHORT_NAMES.get(code)
|
||||
if not label or not short_name:
|
||||
continue
|
||||
items.append(
|
||||
{
|
||||
"code": code,
|
||||
"name": label,
|
||||
"short_name": short_name,
|
||||
"sort_order": sort_order,
|
||||
}
|
||||
)
|
||||
return items
|
||||
|
||||
|
||||
def build_scope_query(scope_codes: Iterable[str]) -> Q:
|
||||
query = Q()
|
||||
for scope_code in scope_codes:
|
||||
|
||||
Reference in New Issue
Block a user