meraproject/services/user-reader/app/member_roles.py
keboss-m 5c21d25d45 Initial commit: Merakomis portal, Docker stack and user-reader API.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-24 11:04:05 +03:00

53 lines
2.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""Справочник ролей в команде проекта (порт eMemberRole.php)."""
from __future__ import annotations
# id -> (title with hierarchy prefix, archive)
_MEMBER_ROLES: dict[int, tuple[str, bool]] = {
2: ("• ГИП", False),
5: ("•• ГАП", False),
6: ("••• Архитектор", False),
11: ("••• Специалист генплана", False),
3: ("•• ГКП", False),
4: ("••• Инженер-конструктор", False),
12: ("••• Инженер-геотехник", False),
13: ("••• Инженер-обследователь", False),
14: ("•• Ведущий инженер ЭОМ", False),
15: ("••• Инженер ЭОМ", False),
16: ("•• Ведущий инженер ССиАК", False),
17: ("••• Инженер ССиАК", False),
18: ("•• Ведущий инженер ВК", False),
19: ("••• Инженер ВК", False),
20: ("•• Ведущий инженер ОВиК", False),
21: ("••• Инженер ОВиК", False),
7: ("•• Ведущий инженер", True),
8: ("••• Инженер", True),
10: ("• BIM-координатор", False),
22: ("• Сотрудник", False),
}
def member_role_title(role_id: int) -> str | None:
entry = _MEMBER_ROLES.get(int(role_id))
return entry[0] if entry else None
def list_member_roles(include_role: int | None = None) -> list[dict[str, int | str]]:
"""Неархивные роли; include_role добавляет архивную текущую роль при edit."""
out: list[dict[str, int | str]] = []
seen: set[int] = set()
for rid, (title, archive) in sorted(_MEMBER_ROLES.items()):
if archive and rid != include_role:
continue
out.append({"id": rid, "title": title})
seen.add(rid)
if include_role and include_role not in seen and include_role in _MEMBER_ROLES:
title, _ = _MEMBER_ROLES[include_role]
out.append({"id": include_role, "title": title})
out.sort(key=lambda x: int(x["id"]))
return out
def is_valid_member_role(role_id: int) -> bool:
return int(role_id) in _MEMBER_ROLES