From af87fa8af3f8fe616b38f7b8eafc26bbc96c2942 Mon Sep 17 00:00:00 2001 From: Anton Date: Wed, 29 Apr 2026 11:34:46 +0300 Subject: [PATCH] fix: avoid Jinja dict items collision in employee card --- README.md | 2 +- app/services/admin_data.py | 2 +- app/templates/employee_detail.html | 4 ++-- app/version.py | 6 +++--- tests/test_admin_data.py | 3 ++- tests/test_api_mcp.py | 2 +- tests/test_employee_detail_template.py | 2 ++ 7 files changed, 12 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index da563ef..b8b3bc5 100644 --- a/README.md +++ b/README.md @@ -110,4 +110,4 @@ docker compose exec postgres pg_dump -U miem miem_workers > backup.sql docker compose down ``` -Версия сервиса: `0.2.3`. Админка всегда показывает версии backend и frontend в footer. +Версия сервиса: `0.2.4`. Админка всегда показывает версии backend и frontend в footer. diff --git a/app/services/admin_data.py b/app/services/admin_data.py index 64f747b..762533c 100644 --- a/app/services/admin_data.py +++ b/app/services/admin_data.py @@ -59,7 +59,7 @@ def employee_detail_payload(employee: Employee) -> dict[str, Any]: "emails": _clean_list(contacts.get("emails")), "phones": _clean_list(contacts.get("phones")), "address": contacts.get("address"), - "items": _normalize_contact_items(contacts.get("items")), + "contact_items": _normalize_contact_items(contacts.get("items")), }, "external_ids": _normalize_external_ids(data.get("external_ids")), "sections": [_normalize_section(section) for section in _as_list(data.get("sections"))], diff --git a/app/templates/employee_detail.html b/app/templates/employee_detail.html index 7eeae72..f00f289 100644 --- a/app/templates/employee_detail.html +++ b/app/templates/employee_detail.html @@ -62,12 +62,12 @@
Адрес
{{ employee_view.contacts.address or "Не указано" }}
- {% if employee_view.contacts.items %} + {% if employee_view.contacts.contact_items %}
Прочее
    - {% for item in employee_view.contacts.items %} + {% for item in employee_view.contacts.contact_items %}
  • {{ item }}
  • {% endfor %}
diff --git a/app/version.py b/app/version.py index 8a15179..5aca819 100644 --- a/app/version.py +++ b/app/version.py @@ -1,3 +1,3 @@ -APP_VERSION = "0.2.3" -FRONTEND_VERSION = "0.2.3" -BACKEND_VERSION = "0.2.3" +APP_VERSION = "0.2.4" +FRONTEND_VERSION = "0.2.4" +BACKEND_VERSION = "0.2.4" diff --git a/tests/test_admin_data.py b/tests/test_admin_data.py index 49062c8..03d8823 100644 --- a/tests/test_admin_data.py +++ b/tests/test_admin_data.py @@ -86,7 +86,7 @@ def test_employee_detail_payload_normalizes_human_readable_sections(db_session): payload = employee_detail_payload(employee) assert payload["contacts"]["emails"] == ["person@hse.ru"] - assert payload["contacts"]["items"] == ["consultation hours"] + assert payload["contacts"]["contact_items"] == ["consultation hours"] assert payload["external_ids"][0]["system"] == "ORCID" assert payload["sections"][0]["year_entries"][0]["text"] == "Master degree" assert payload["sections"][1]["publications"][0]["title"] == "Paper" @@ -111,6 +111,7 @@ def test_employee_payloads_tolerate_malformed_current_data(db_session): assert display["positions"] == [] assert display["email_text"] == "" assert detail["contacts"]["emails"] == [] + assert detail["contacts"]["contact_items"] == [] assert detail["sections"] == [] diff --git a/tests/test_api_mcp.py b/tests/test_api_mcp.py index 1433858..8a9c05a 100644 --- a/tests/test_api_mcp.py +++ b/tests/test_api_mcp.py @@ -18,7 +18,7 @@ def test_health_returns_versions(): response = client.get("/api/health") assert response.status_code == 200 - assert response.json()["backend_version"] == "0.2.3" + assert response.json()["backend_version"] == "0.2.4" def test_mcp_requires_token_and_lists_tools(): diff --git a/tests/test_employee_detail_template.py b/tests/test_employee_detail_template.py index c7443cf..192ac4f 100644 --- a/tests/test_employee_detail_template.py +++ b/tests/test_employee_detail_template.py @@ -7,6 +7,8 @@ def test_employee_detail_template_is_human_readable(): assert "Current data" not in template assert "
Tabs<" not in template
+    assert "contacts.items" not in template
+    assert "contacts.contact_items" in template
     assert "Основная информация" in template
     assert "Контакты" in template
     assert "Разделы профиля" in template
-- 
2.49.1