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-01-22 01:33:42 +03:00
2026-02-12 15:59:53 +03:00
2025-12-26 13:49:51 +03:00
2026-02-16 17:07:15 +03:00
2026-01-06 09:22:16 +03:00
2025-12-26 13:49:51 +03:00
2026-01-14 11:18:35 +03:00
2026-01-15 13:48:11 +03:00
2026-01-13 09:18:25 +03:00
2026-01-12 17:37:41 +03:00
2026-01-13 09:18:25 +03:00
2026-01-06 09:22:16 +03:00
2026-01-12 17:21:41 +03:00