fix: remove duplicate exclusion block, replace continue with else branch

- Removed duplicate department exclusion check (was duplicated twice)
- Replaced 'continue' (invalid inside 'if ENABLE_AUTO_APPROVAL') with 'else:' branch
- Properly indented auto-approval logic inside the else block
This commit is contained in:
gitea
2026-07-04 18:50:40 +07:00
parent c3503975a0
commit 23960cbbb6
+16 -29
View File
@@ -899,35 +899,22 @@ def process_ticket_logic(req_id):
break
if is_excluded:
t_log(" ⏭ Пропуск: пользователь в исключённом отделе.")
continue
# Проверка: отдел пользователя в списке исключений
is_excluded = False
if user_department and APPROVAL_EXCLUDED_DEPARTMENTS:
for dept in APPROVAL_EXCLUDED_DEPARTMENTS:
if dept.lower() in user_department.lower() or user_department.lower() in dept.lower():
is_excluded = True
t_log(f" ⚠️ Отдел '{user_department}' в списке исключений — автосогласование отменено")
break
if is_excluded:
t_log(" ⏭ Пропуск: пользователь в исключённом отделе.")
continue
if is_city_ok and (is_group_ok or is_cat_ok):
if manager_email:
t_log(f"✔ Условия совпали. Запуск процесса согласования для {manager_email}...")
ai_was_used = True
share_success, share_log = share_ticket_for_approval(req_id, manager_email)
t_log(share_log)
cc_success, cc_log = add_email_to_notify(req_id, manager_email)
t_log(cc_log)
success, step_detail = trigger_manager_approval(req_id, manager_email)
t_log(step_detail)
else:
t_log("⚠️ Согласование невозможно: у пользователя не указан руководитель в AD.")
else:
if is_city_ok and (is_group_ok or is_cat_ok):
if manager_email:
t_log(f"✔ Условия совпали. Запуск процесса согласования для {manager_email}...")
ai_was_used = True
share_success, share_log = share_ticket_for_approval(req_id, manager_email)
t_log(share_log)
cc_success, cc_log = add_email_to_notify(req_id, manager_email)
t_log(cc_log)
success, step_detail = trigger_manager_approval(req_id, manager_email)
t_log(step_detail)
else:
t_log("⚠️ Согласование невозможно: у пользователя не указан руководитель в AD.")
else:
if ai_was_used:
t_log("\n=== ШАГ 5. АВТОСОГЛАСОВАНИЕ ===")