Corp/backend/eusrr_backend
lizerk 51aecacf09 feat(communications): Refactor Chat model to universal GenericForeignKey
BREAKING CHANGES (backward compatible with data migration):
- Add context_object (GenericFK) to replace department FK
- Add flags (JSONField) to replace is_main boolean
- Add extra_data (JSONField) for extensibility
- Rename include_all_employees → include_all_users

NEW FEATURES:
- Generic context support (Department, Project, Team, etc.)
- Flexible flags system without migrations
- Settings-based participant resolver callback
- Zero data loss migrations (4 migrations)

MIGRATIONS:
- 0031: Add new fields (context_object, flags, extra_data)
- 0032: Migrate department → context_object (15 chats)
- 0033: Migrate is_main → flags['is_primary'] (15 chats)
- 0034: Rename include_all_employees → include_all_users

FILES CHANGED:
- models.py: Refactored Chat.get_participants() with callback support
- employees/utils.py: Added resolve_chat_participants() callback
- settings.py: Added COMMUNICATIONS_PARTICIPANT_RESOLVER setting
- verify_chat_migration.py: Command to verify data integrity

TESTED:
✅ All 32 chats migrated successfully
✅ Legacy department FK still works
✅ Context-based chats work (GenericFK)
✅ Global/private/announcement chats work
✅ Participants resolver callback works
2026-03-11 14:21:57 +03:00
..
2026-03-10 17:00:51 +03:00