From 70f9c1950d2f3f84f173d26a09e965963de0e6a6 Mon Sep 17 00:00:00 2001 From: lizerk Date: Mon, 9 Mar 2026 10:05:57 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D1=8B=20URL-=D1=8B=20=D0=B2=20=D1=83=D0=B2?= =?UTF-8?q?=D0=B5=D0=B4=D0=BE=D0=BC=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=D1=85=20?= =?UTF-8?q?=D0=BD=D0=B0=20=D1=81=D1=83=D1=89=D0=B5=D1=81=D1=82=D0=B2=D1=83?= =?UTF-8?q?=D1=8E=D1=89=D0=B8=D0=B5=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=86=D1=8B=20=D1=84=D1=80=D0=BE=D0=BD=D1=82=D0=B5=D0=BD=D0=B4?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - /requests/{id}/ → /requests - /documents/{id}/ → /documents - /calendar (вместо /?event_id={id}) - /procurement/orders/{id}/ → /procurement - /messages (вместо /communications/chats/{id}/) - / для постов ленты Теперь клик по уведомлениям не вызывает 404 ошибки --- backend/api/v1/procurement/views.py | 20 +++++++++---------- backend/calendar_app/notification_signals.py | 7 ++----- .../communications/notification_signals.py | 8 ++++---- backend/documents/notification_signals.py | 10 +++++----- backend/feed/notification_signals.py | 6 +++--- backend/notifications/task_base.py | 4 ++-- backend/procurement/signals.py | 6 +++--- backend/requests_app/notification_signals.py | 6 +++--- 8 files changed, 32 insertions(+), 35 deletions(-) diff --git a/backend/api/v1/procurement/views.py b/backend/api/v1/procurement/views.py index 5766cb66..b99b6ffb 100644 --- a/backend/api/v1/procurement/views.py +++ b/backend/api/v1/procurement/views.py @@ -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, ) diff --git a/backend/calendar_app/notification_signals.py b/backend/calendar_app/notification_signals.py index 07ea6567..afec4b53 100644 --- a/backend/calendar_app/notification_signals.py +++ b/backend/calendar_app/notification_signals.py @@ -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' diff --git a/backend/communications/notification_signals.py b/backend/communications/notification_signals.py index 74ceadcc..63d80aa7 100644 --- a/backend/communications/notification_signals.py +++ b/backend/communications/notification_signals.py @@ -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, diff --git a/backend/documents/notification_signals.py b/backend/documents/notification_signals.py index f3d09281..4b1645a0 100644 --- a/backend/documents/notification_signals.py +++ b/backend/documents/notification_signals.py @@ -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, diff --git a/backend/feed/notification_signals.py b/backend/feed/notification_signals.py index 44eaeaf6..8dc1332b 100644 --- a/backend/feed/notification_signals.py +++ b/backend/feed/notification_signals.py @@ -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, diff --git a/backend/notifications/task_base.py b/backend/notifications/task_base.py index aebc77f8..f30ad0cc 100644 --- a/backend/notifications/task_base.py +++ b/backend/notifications/task_base.py @@ -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, diff --git a/backend/procurement/signals.py b/backend/procurement/signals.py index a9f76e97..015eafbc 100644 --- a/backend/procurement/signals.py +++ b/backend/procurement/signals.py @@ -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, ) diff --git a/backend/requests_app/notification_signals.py b/backend/requests_app/notification_signals.py index e0b44238..324114ff 100644 --- a/backend/requests_app/notification_signals.py +++ b/backend/requests_app/notification_signals.py @@ -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,