diff --git a/app/services/admin_data.py b/app/services/admin_data.py index c590ce5..2255685 100644 --- a/app/services/admin_data.py +++ b/app/services/admin_data.py @@ -55,7 +55,8 @@ def _has_training(data: dict[str, Any], since_year: int | None) -> bool: section = _as_dict(value) title = str(section.get("title") or "").casefold().strip().rstrip(":") dedicated = title in {_TRAINING_LABEL, "курсы повышения квалификации"} - if not dedicated and _TRAINING_LABEL not in (part.strip() for part in title.split("/")): + if (section.get("type") != "additional_education" and not dedicated + and _TRAINING_LABEL not in (part.strip() for part in title.split("/"))): continue structured_texts = set() for value in _as_list(section.get("year_entries")): diff --git a/tests/test_training_filter.py b/tests/test_training_filter.py index 0896626..4448b23 100644 --- a/tests/test_training_filter.py +++ b/tests/test_training_filter.py @@ -113,3 +113,16 @@ def test_training_filter_uses_course_year_and_kind_before_pagination(db_session) assert client.get("/admin/directory?training_since_year=bad").status_code == 422 finally: app.dependency_overrides.clear() + + +@pytest.mark.parametrize(("content", "matches"), [ + ("Курс повышения квалификации по Python", True), + ("Стажировка в университете", False), +]) +def test_short_education_section_title_does_not_hide_course(db_session, content, matches): + url = "https://example.test/profile" + soup = BeautifulSoup(f"
2025. {content}.
", "html.parser") + db_session.add(Employee(profile_key="training:short", canonical_url=url, + current_data={"sections": extract_sections(soup, url)})) + db_session.commit() + assert list_employees_page(db_session, training_since_year=2024)["total"] == int(matches)