Исправить заполнение вида и года распознанного курса
CI / test (pull_request) Successful in 12m36s
CI / Fingerprint diagnostics (production deployment temporarily disabled) (pull_request) Skipped

This commit is contained in:
codex committed 2026-11-25 19:18:49 +03:00
1 parent a4b188d562
commit 7d1939a598
2 files changed
+16 -4

No files matched your search

+7 -3
View File
@@ -134,15 +134,19 @@ def dpo_source_digest(education):
def dpo_suggestions(education):
courses = []
for section in education:
years = {entry.get("text"): entry["year"] for entry in _as_list(section.get("year_entries"))
if isinstance(entry, dict) and type(entry.get("year")) is int}
for title in section.get("items", []):
dedicated = str(section.get("title") or "").casefold().strip().rstrip(":") in {
_TRAINING_LABEL, "курсы повышения квалификации"}
text = _QUOTED_TEXT.sub("", title)
year = _TRAINING_YEAR.search(text)
kind = "training" if dedicated or _TRAINING_KIND.search(text) or _TRAINING_MENTION.search(text) else "other"
year = years.get(title)
if year is None and (match := _TRAINING_YEAR.search(text)):
year = int(match.group(1) or match.group(2))
kind = "training" if dedicated or _TRAINING_MENTION.search(text) else "other"
if "переподготовк" in text.casefold():
kind = "retraining"
courses.append({"title": title, "kind": kind, "year": int(year.group(1) or year.group(2)) if year else None,
courses.append({"title": title, "kind": kind, "year": year,
"evidence": ""})
return courses
+9 -1
View File
@@ -438,8 +438,16 @@ def test_reader_confirms_dpo_and_changed_sources_require_review(accounts):
client, db, settings, _, user, employee = accounts
headers = act_as(client, user, settings)
url = f"/admin/employees/{employee.id}/dpo"
title = "Работа с данными, повышение квалификации"
section = {"type": "additional_education", "title": "Дополнительное образование",
"education_format": 2, "items": [title], "year_entries": [{"text": title, "year": 2024}]}
employee.current_data = {"sections": [section]}
db.commit()
card = BeautifulSoup(client.get(url[:-4]).text, "html.parser")
form = card.select_one("form[data-dpo]")
assert form.select_one('[name="title"]')["value"] == title
assert form.select_one('[name="kind"] option[selected]')["value"] == "training"
assert form.select_one('[name="year"]')["value"] == "2024"
payload = {"courses": [{"title": "Инженерная практика", "kind": "training", "year": 2025}],
"source": form["data-source"], "revision": 0}
assert client.post(url, json=payload).status_code == 403
@@ -450,7 +458,7 @@ def test_reader_confirms_dpo_and_changed_sources_require_review(accounts):
assert [row["dpo_count"] for row in result] == [1]
sheet = load_workbook(BytesIO(directory_xlsx(result))).active
assert sheet.cell(2, sheet.max_column).value == 1
employee.current_data = {"sections": [], "phone": "changed"}
employee.current_data = {"sections": [section], "phone": "changed"}
db.commit()
assert not employee_detail_payload(employee)["dpo_uncertain"]
employee.current_data = {"sections": [{"type": "additional_education", "education_format": 2,