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-11 14:21:57 +03:00
2026-03-11 14:21:57 +03:00
2026-03-10 17:00:51 +03:00
2025-08-05 15:30:41 +03:00
2026-01-15 12:15:44 +03:00
2026-03-10 13:27:32 +03:00
2025-08-08 15:16:19 +03:00
2026-03-11 14:21:57 +03:00
2026-02-28 00:13:46 +03:00
2026-03-10 14:20:56 +03:00
2026-03-10 18:09:06 +03:00
2026-01-15 11:13:54 +03:00
2026-02-25 20:29:00 +03:00