igor_nadein
59b8f56c5a
refactor(employees): simplify create() using ExternalSystemSyncMixin
Replaced 150+ lines of manual transaction management with mixin:
Before:
- Manual transaction.atomic()
- Manual LDAP sync calls
- Duplicate code for LDAP/non-LDAP modes
- Manual error handling and rollback
- ~150 lines of boilerplate
After:
- create() delegates to super() - миксин управляет всем
- perform_create() - только БД логика (30 lines)
- handle_external_sync_result() - обработка LDAP результата
- Миксин автоматически управляет транзакциями и откатами
Changes:
1. create(): simplified to validation + super().create()
2. perform_create(): creates Employee in DB, sets password/avatar/skills
3. prepare_external_data(): builds DTO with avatar_bytes, group_cns
4. handle_external_sync_result(): saves DN/GUID to LdapSyncState,
sets employeeNumber, assigns position
5. ExternalSystemSyncMixin: added handle_external_sync_result() hook
for custom post-sync actions
Code reduction: 150 lines -> 80 lines
Benefits: cleaner, DRYer, automatic error handling
manage.py check: no issues
2026-02-16 17:07:15 +03:00
..
2026-02-16 17:07:15 +03:00
2025-09-09 17:55:15 +03:00
2026-02-12 15:59:53 +03:00
2026-02-16 17:07:15 +03:00
2026-01-22 01:33:42 +03:00
2026-02-16 17:07:15 +03:00
2026-01-09 14:56:44 +03:00
2026-02-16 17:07:15 +03:00
2026-02-16 16:21:45 +03:00
2026-01-09 14:48:43 +03:00
2025-11-20 09:00:55 +03:00
2026-01-13 10:19:26 +03:00
2026-01-22 01:33:42 +03:00
2026-01-22 01:33:42 +03:00
2026-01-13 15:02:29 +03:00
2025-09-11 17:56:33 +03:00
2026-02-12 16:04:34 +03:00
2026-02-12 15:59:53 +03:00
2026-02-16 17:07:15 +03:00
2025-07-30 08:15:53 +03:00
2026-01-05 10:47:56 +03:00
2026-01-08 16:14:00 +03:00
2026-02-11 12:52:25 +03:00
2025-11-20 09:00:55 +03:00
2025-09-03 17:17:44 +03:00
2026-02-11 12:52:25 +03:00
2025-07-30 08:15:53 +03:00
2026-01-05 07:41:34 +03:00
2026-01-22 01:33:42 +03:00
2026-01-08 16:14:00 +03:00
2026-01-06 07:48:04 +03:00
2026-02-11 12:52:25 +03:00
2026-02-11 12:52:25 +03:00
2026-01-08 16:55:54 +03:00
2026-01-09 15:07:55 +03:00
2026-01-22 01:33:42 +03:00
2026-01-22 01:33:42 +03:00
2026-01-22 01:33:42 +03:00
2026-02-12 15:59:53 +03:00
2026-01-13 09:18:25 +03:00