81 lines
2.9 KiB
Python
81 lines
2.9 KiB
Python
"""
|
||
Модуль уведомлений для приложения Procurement.
|
||
|
||
Обеспечивает автоматическую отправку уведомлений при:
|
||
- Создании новой заявки на закупку
|
||
- Изменении статуса заявки
|
||
- Создании/изменении согласования
|
||
|
||
Использует универсальную систему уведомлений (backend/notifications).
|
||
Все уведомления (включая WebSocket) отправляются через notify.send().
|
||
|
||
Структура:
|
||
- config.py - конфигурация (типы уведомлений, шаблоны, URLs)
|
||
- handlers.py - бизнес-логика отправки уведомлений
|
||
- signals.py - Django сигналы для автоматической генерации
|
||
|
||
Usage:
|
||
# Сигналы подключаются автоматически через AppConfig.ready()
|
||
# Для ручной отправки:
|
||
from procurement.notifications import notify_request_comment
|
||
notify_request_comment(request_obj, message_obj, actor=user)
|
||
|
||
# WebSocket broadcast происходит автоматически через:
|
||
# notify.send() → channels.py → Celery → WebSocketNotificationSender
|
||
"""
|
||
|
||
# Импорты для удобства и обратной совместимости
|
||
# Сигналы импортируются для регистрации через AppConfig.ready()
|
||
from . import signals # noqa: F401
|
||
from .config import ActionURLs, MessageTemplates, NotificationVerbs
|
||
from .handlers import (
|
||
notify_approver,
|
||
notify_approvers,
|
||
notify_executor_reassigned,
|
||
notify_item_comment,
|
||
notify_item_issue_reported,
|
||
notify_item_updated,
|
||
notify_new_request,
|
||
notify_processing_department_request,
|
||
notify_request_approved,
|
||
notify_request_arrival,
|
||
notify_request_cancelled,
|
||
notify_request_comment,
|
||
notify_request_completed,
|
||
notify_request_in_progress,
|
||
notify_request_rejected,
|
||
notify_request_returned_to_processing,
|
||
notify_requestor,
|
||
notify_stage_approved,
|
||
notify_stage_rejected,
|
||
)
|
||
|
||
__all__ = [
|
||
# Config
|
||
"NotificationVerbs",
|
||
"MessageTemplates",
|
||
"ActionURLs",
|
||
# Handlers
|
||
"notify_new_request",
|
||
"notify_approvers",
|
||
"notify_approver",
|
||
"notify_processing_department_request",
|
||
"notify_requestor",
|
||
"notify_request_approved",
|
||
"notify_request_rejected",
|
||
"notify_request_completed",
|
||
"notify_request_arrival",
|
||
"notify_request_in_progress",
|
||
"notify_executor_reassigned",
|
||
"notify_request_returned_to_processing",
|
||
"notify_request_cancelled",
|
||
"notify_stage_approved",
|
||
"notify_stage_rejected",
|
||
"notify_item_updated",
|
||
"notify_item_issue_reported",
|
||
"notify_request_comment",
|
||
"notify_item_comment",
|
||
# Signals module (для импорта в AppConfig)
|
||
"signals",
|
||
]
|