Corp/backend/notifications/test_views.py
Игорь Надеин d7c025f120 feat: Add department-based document distribution with department picker in UI
- Added departments ManyToMany field to Document model
- Implemented department selection in document create/edit modals
- Added automatic notification creation for all department employees
- Fixed document filtering to include uploaded documents in 'My Documents'
- Fixed acknowledgements API to include department recipients
- Added bulk notification support with configurable threshold
- Removed acknowledge button, added visual highlighting for unread documents
- Implemented server-side acknowledgment flow with redirect to file
- Fixed mobile responsive layout for document actions
- Removed temporary test files and documentation
2025-11-21 12:46:43 +03:00

32 lines
1.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
Тестовый view для создания уведомлений
"""
from django.http import JsonResponse
from django.contrib.auth.decorators import login_required
from notifications.services import NotificationService
@login_required
def create_test_notification(request):
"""Создать тестовое уведомление для текущего пользователя"""
notification = NotificationService.create_notification(
recipient=request.user,
notification_type_code='system_announcement',
title='🎉 Тестовое уведомление',
message='Это тестовое сообщение отправлено через API. Вы должны увидеть toast!',
action_url='/notifications/',
action_text='Открыть уведомления'
)
if notification:
return JsonResponse({
'success': True,
'notification_id': notification.id,
'message': 'Уведомление создано и отправлено'
})
else:
return JsonResponse({
'success': False,
'message': 'Не удалось создать уведомление'
}, status=400)