fix: исправлены URL-ы в уведомлениях на существующие страницы фронтенда
- /requests/{id}/ → /requests
- /documents/{id}/ → /documents
- /calendar (вместо /?event_id={id})
- /procurement/orders/{id}/ → /procurement
- /messages (вместо /communications/chats/{id}/)
- / для постов ленты
Теперь клик по уведомлениям не вызывает 404 ошибки
This commit is contained in:
parent
bd1238b3da
commit
70f9c1950d
@ -184,7 +184,7 @@ class ProcurementRequestViewSet(viewsets.ModelViewSet):
|
||||
f'Остаток: {budget.remaining_amount}₽ '
|
||||
f'({remaining_ratio*100:.1f}%)'
|
||||
),
|
||||
action_url='/procurement/budgets/',
|
||||
action_url='/procurement',
|
||||
send_immediately=True,
|
||||
)
|
||||
elif remaining_ratio <= LOW_BUDGET_THRESHOLD:
|
||||
@ -198,7 +198,7 @@ class ProcurementRequestViewSet(viewsets.ModelViewSet):
|
||||
f'Остаток: {budget.remaining_amount}₽ '
|
||||
f'({remaining_ratio*100:.1f}%)'
|
||||
),
|
||||
action_url='/procurement/budgets/',
|
||||
action_url='/procurement',
|
||||
send_immediately=True,
|
||||
)
|
||||
|
||||
@ -289,7 +289,7 @@ class ProcurementRequestViewSet(viewsets.ModelViewSet):
|
||||
f'ожидает вашего согласования. '
|
||||
f'Сумма: {procurement_request.total_cost}₽'
|
||||
),
|
||||
action_url=f'/procurement/orders/{procurement_request.id}/',
|
||||
action_url='/procurement',
|
||||
send_immediately=True,
|
||||
)
|
||||
|
||||
@ -330,7 +330,7 @@ class ProcurementRequestViewSet(viewsets.ModelViewSet):
|
||||
f'{request.user.get_full_name()} одобрил '
|
||||
f'заявку "{procurement_request.title}".'
|
||||
),
|
||||
action_url=f'/procurement/orders/{procurement_request.id}/',
|
||||
action_url='/procurement',
|
||||
send_immediately=True,
|
||||
)
|
||||
|
||||
@ -353,7 +353,7 @@ class ProcurementRequestViewSet(viewsets.ModelViewSet):
|
||||
f'Ваша заявка "{procurement_request.title}" '
|
||||
f'была полностью одобрена. Можно приступать к закупке.'
|
||||
),
|
||||
action_url=f'/procurement/orders/{procurement_request.id}/',
|
||||
action_url='/procurement',
|
||||
send_immediately=True,
|
||||
)
|
||||
|
||||
@ -402,7 +402,7 @@ class ProcurementRequestViewSet(viewsets.ModelViewSet):
|
||||
f'заявку "{procurement_request.title}". '
|
||||
f'Причина: {approval.comment}'
|
||||
),
|
||||
action_url=f'/procurement/orders/{procurement_request.id}/',
|
||||
action_url='/procurement',
|
||||
send_immediately=True,
|
||||
)
|
||||
|
||||
@ -513,7 +513,7 @@ class ProcurementRequestViewSet(viewsets.ModelViewSet):
|
||||
f'взята в работу пользователем '
|
||||
f'{request.user.get_full_name()}.'
|
||||
),
|
||||
action_url=f'/procurement/orders/{procurement_request.id}/',
|
||||
action_url='/procurement',
|
||||
send_immediately=True,
|
||||
)
|
||||
|
||||
@ -530,7 +530,7 @@ class ProcurementRequestViewSet(viewsets.ModelViewSet):
|
||||
f'взята в работу пользователем '
|
||||
f'{request.user.get_full_name()}.'
|
||||
),
|
||||
action_url=f'/procurement/orders/{procurement_request.id}/',
|
||||
action_url='/procurement',
|
||||
send_immediately=True,
|
||||
)
|
||||
|
||||
@ -576,7 +576,7 @@ class ProcurementRequestViewSet(viewsets.ModelViewSet):
|
||||
f'Заявка "{procurement_request.title}" '
|
||||
f'успешно завершена.'
|
||||
),
|
||||
action_url=f'/procurement/orders/{procurement_request.id}/',
|
||||
action_url='/procurement',
|
||||
send_immediately=True,
|
||||
)
|
||||
|
||||
@ -659,7 +659,7 @@ class ProcurementRequestViewSet(viewsets.ModelViewSet):
|
||||
f'была отменена автором. '
|
||||
f'Причина: {reason or "не указана"}'
|
||||
),
|
||||
action_url=f'/procurement/orders/{procurement_request.id}/',
|
||||
action_url='/procurement',
|
||||
send_immediately=True,
|
||||
)
|
||||
|
||||
|
||||
@ -255,9 +255,6 @@ def get_event_recipients(event):
|
||||
|
||||
def get_calendar_url(event):
|
||||
"""
|
||||
Возвращает URL календаря в зависимости от типа события.
|
||||
Для всех типов событий используем параметр event_id для прямого открытия.
|
||||
Возвращает URL календаря.
|
||||
"""
|
||||
# Возвращаем главную страницу календаря с параметром event_id
|
||||
# Это позволит открыть модал события автоматически
|
||||
return f'/?event_id={event.id}'
|
||||
return '/calendar'
|
||||
|
||||
@ -146,7 +146,7 @@ def _create_message_notifications_sync(instance):
|
||||
title=f'Вас упомянул {author.get_full_name() or author.username}',
|
||||
message=truncate_message(content, 100),
|
||||
content_object=instance,
|
||||
action_url=f'/communications/chats/{chat.id}/?message={instance.id}',
|
||||
action_url='/messages',
|
||||
metadata={
|
||||
'chat_id': chat.id,
|
||||
'chat_name': get_chat_name(chat),
|
||||
@ -170,7 +170,7 @@ def _create_message_notifications_sync(instance):
|
||||
title=f'{author.get_full_name() or author.username} ответил на ваше сообщение',
|
||||
message=truncate_message(content, 100),
|
||||
content_object=instance,
|
||||
action_url=f'/communications/chats/{chat.id}/?message={instance.id}',
|
||||
action_url='/messages',
|
||||
metadata={
|
||||
'chat_id': chat.id,
|
||||
'chat_name': get_chat_name(chat),
|
||||
@ -219,7 +219,7 @@ def _create_message_notifications_sync(instance):
|
||||
title=title,
|
||||
message=truncate_message(content, 150 if is_announcement else 100),
|
||||
content_object=instance,
|
||||
action_url=f'/communications/chats/{chat.id}/',
|
||||
action_url='/messages',
|
||||
metadata=metadata
|
||||
)
|
||||
|
||||
@ -260,7 +260,7 @@ def create_chat_added_notifications(sender, instance, action, pk_set, **kwargs):
|
||||
title=f'Вас добавили в чат',
|
||||
message=f'Вы были добавлены в чат "{get_chat_name(chat)}"',
|
||||
content_object=chat,
|
||||
action_url=f'/communications/chats/{chat.id}/',
|
||||
action_url='/messages',
|
||||
metadata={
|
||||
'chat_id': chat.id,
|
||||
'chat_type': chat.type,
|
||||
|
||||
@ -358,7 +358,7 @@ def check_all_acknowledged(sender, instance, created, **kwargs):
|
||||
f'"{document.title}"'
|
||||
),
|
||||
content_object=document,
|
||||
action_url='/documents/',
|
||||
action_url='/documents',
|
||||
metadata={
|
||||
'document_id': document.id,
|
||||
'total_recipients': total_recipients,
|
||||
@ -477,7 +477,7 @@ def create_document_ready_notification(document, recipient, send_immediately=Tru
|
||||
f'Требуется ознакомление.'
|
||||
),
|
||||
content_object=document,
|
||||
action_url='/documents/',
|
||||
action_url='/documents',
|
||||
metadata={
|
||||
'document_id': document.id,
|
||||
'uploaded_by_id': (
|
||||
@ -549,7 +549,7 @@ def notify_on_new_comment(sender, instance, created, **kwargs):
|
||||
f'комментарий к документу "{document.title}"'
|
||||
),
|
||||
content_object=comment,
|
||||
action_url=f'/documents/{document.pk}/#comment-{comment.pk}',
|
||||
action_url='/documents',
|
||||
action_text='Посмотреть',
|
||||
metadata={
|
||||
'document_id': document.id,
|
||||
@ -589,7 +589,7 @@ def notify_on_new_comment(sender, instance, created, **kwargs):
|
||||
f'к вашему документу "{document.title}"'
|
||||
),
|
||||
content_object=comment,
|
||||
action_url=f'/documents/{document.pk}/#comment-{comment.pk}',
|
||||
action_url='/documents',
|
||||
action_text='Посмотреть',
|
||||
metadata={
|
||||
'document_id': document.id,
|
||||
@ -646,7 +646,7 @@ def notify_on_related_document_added(sender, instance, action, pk_set, **kwargs)
|
||||
f'с документом "{main_document.title}"'
|
||||
),
|
||||
content_object=main_document,
|
||||
action_url=f'/documents/{main_document.pk}/',
|
||||
action_url='/documents',
|
||||
action_text='Посмотреть',
|
||||
metadata={
|
||||
'document_id': main_document.id,
|
||||
|
||||
@ -77,7 +77,7 @@ def create_comment_notification(sender, instance, created, **kwargs):
|
||||
f' прокомментировал: {truncate_text(comment.text, 80)}'
|
||||
),
|
||||
content_object=post,
|
||||
action_url=f'/post/{post.id}/',
|
||||
action_url='/',
|
||||
metadata={
|
||||
'post_id': post.id,
|
||||
'post_title': post.title,
|
||||
@ -115,7 +115,7 @@ def notify_new_post(post):
|
||||
title=f'Новая публикация {context}',
|
||||
message=f'{post.title}',
|
||||
content_object=post,
|
||||
action_url=f'/post/{post.id}/',
|
||||
action_url='/',
|
||||
metadata={
|
||||
'post_id': post.id,
|
||||
'post_type': post.type,
|
||||
@ -191,7 +191,7 @@ def notify_post_reaction(post, user):
|
||||
f'понравилась публикация "{post.title}"'
|
||||
),
|
||||
content_object=post,
|
||||
action_url=f'/post/{post.id}/',
|
||||
action_url='/',
|
||||
metadata={
|
||||
'post_id': post.id,
|
||||
'post_title': post.title,
|
||||
|
||||
@ -537,7 +537,7 @@ class RequestNotificationProcessor(BaseNotificationProcessor):
|
||||
title=title_map.get(notification_type, f'Обновление заявки #{request_obj.id}'),
|
||||
message=truncate_text(request_obj.comment or '', 150),
|
||||
content_object=request_obj,
|
||||
action_url=f'/requests/{request_obj.id}/',
|
||||
action_url='/requests',
|
||||
metadata={
|
||||
'request_id': request_obj.id,
|
||||
'request_type': request_obj.type,
|
||||
@ -594,7 +594,7 @@ class DocumentNotificationProcessor(BaseNotificationProcessor):
|
||||
title=f'Новый документ: {document.title}',
|
||||
message=truncate_text(document.description or '', 150),
|
||||
content_object=document,
|
||||
action_url=f'/documents/{document.id}/',
|
||||
action_url='/documents',
|
||||
metadata={
|
||||
'document_id': document.id,
|
||||
'document_title': document.title,
|
||||
|
||||
@ -80,7 +80,7 @@ def notify_on_request_status_change(sender, instance, created, **kwargs):
|
||||
f'Создана заявка "{instance.title}" '
|
||||
f'на сумму {instance.total_cost}₽'
|
||||
),
|
||||
action_url=f'/procurement/requests/{instance.id}/',
|
||||
action_url='/procurement',
|
||||
send_immediately=True,
|
||||
)
|
||||
return
|
||||
@ -189,7 +189,7 @@ def notify_approver(approval):
|
||||
f'ожидает вашего согласования. '
|
||||
f'Сумма: {approval.request.total_cost}₽'
|
||||
),
|
||||
action_url=f'/procurement/requests/{approval.request.id}/',
|
||||
action_url='/procurement',
|
||||
send_immediately=True,
|
||||
)
|
||||
|
||||
@ -201,7 +201,7 @@ def notify_requestor(request, notification_type_code, title, message):
|
||||
notification_type_code=notification_type_code,
|
||||
title=title,
|
||||
message=message,
|
||||
action_url=f'/procurement/requests/{request.id}/',
|
||||
action_url='/procurement',
|
||||
send_immediately=True,
|
||||
)
|
||||
|
||||
|
||||
@ -269,7 +269,7 @@ def create_comment_notification(sender, instance, created, **kwargs):
|
||||
f'"{request_type}": {instance.text[:100]}'
|
||||
),
|
||||
content_object=request_obj,
|
||||
action_url=f"/requests/{request_obj.id}/",
|
||||
action_url="/requests",
|
||||
metadata={
|
||||
"request_id": request_obj.id,
|
||||
"request_type": request_obj.type,
|
||||
@ -457,7 +457,7 @@ def notify_new_request(request_obj):
|
||||
title=title,
|
||||
message=message,
|
||||
content_object=request_obj,
|
||||
action_url=f"/requests/{request_obj.id}/",
|
||||
action_url="/requests",
|
||||
metadata={
|
||||
"request_id": request_obj.id,
|
||||
"request_type": request_obj.type,
|
||||
@ -562,7 +562,7 @@ def notify_status_change(request_obj, old_status, new_status):
|
||||
title=title,
|
||||
message=message,
|
||||
content_object=request_obj,
|
||||
action_url=f"/requests/{request_obj.id}/",
|
||||
action_url="/requests",
|
||||
metadata={
|
||||
"request_id": request_obj.id,
|
||||
"request_type": request_obj.type,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user