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 16:32:12 +03:00
2025-07-30 08:15:53 +03:00
2025-12-01 14:19:58 +03:00
2026-02-16 17:07:15 +03:00
2025-07-30 08:15:53 +03:00
2025-07-30 08:15:53 +03:00
2025-08-25 17:01:58 +03:00
2025-12-05 10:28:23 +03:00
2025-08-25 17:01:58 +03:00
2025-11-20 18:52:29 +03:00
2025-12-29 15:48:19 +03:00
2026-01-09 15:13:36 +03:00