2 Commits

Author SHA1 Message Date
lizerk
0217bc1a38 refactor: migrate comments to unified communications system
- Delete legacy Comment models (feed.Comment, documents.DocumentComment, requests_app.RequestComment)
- Create migration scripts to move data to communications.Message
- Add comments_helpers.py for unified comment operations
- Update API endpoints: /api/v1/posts/{id}/comments/, /api/v1/requests/{id}/comments/
- Fix notifications.0010_drop_old_tables migration with SeparateDatabaseAndState
- Implement real-time comments_count via GenericForeignKey annotations
- Update frontend API client to use new endpoints
- Update JavaScript files for new comment API routes
- Remove deprecated API endpoints and serializers
- Clean up signal handlers and admin registrations

Deployment tested: all migrations apply successfully on fresh database
2026-03-11 23:56:41 +03:00
lizerk
cc24a073f4 refactor(documents): реструктуризация notifications в модульную архитектуру
Проблема:
- Монолитный notification_signals.py (~520 строк) смешивал разные concerns
- Сложная логика с множественными сигналами и обработчиками в одном файле
- Логирование и бизнес-логика переплетены с signal receivers

Решение:
Разделен на модульную структуру documents/notifications/:
- config.py - NotificationVerbs, MessageTemplates, ActionURLs, get_uploader_name(),
  get_bulk_threshold()
- handlers.py - notify_all_employees(), notify_specific_users(),
  notify_department_employees(), notify_all_acknowledged(), notify_document_comment(),
  notify_comment_reply()
- signals.py - Django signal receivers (@receiver) для Document, DocumentAcknowledgement,
  DocumentComment
- __init__.py - публичный API модуля

Изменения:
- Создан: documents/notifications/ модуль с 4 файлами
- Переименован: notification_signals.py → notification_signals.py.old
- Изменен: apps.py - обновлен импорт на documents.notifications

Логика уведомлений:
1. Новый документ → все сотрудники/отделы/конкретные получатели
2. Все ознакомились → уведомление загрузившему
3. Комментарий → автор документа
4. Ответ на комментарий → автор родительского комментария

Преимущества:
- ✅ Единообразие с requests_app, procurement, feed, communications
- ✅ Четкое разделение ответственности (SRP)
- ✅ Централизованное логирование с контекстом
- ✅ Поддержка bulk режима для массовых рассылок
- ✅ Легче тестировать компоненты
- ✅ Публичный API для переиспользования

Верификация:
- python manage.py check - успешно
2026-03-10 13:36:04 +03:00