From b38d2bc44bc26db51162af9cec751ce937f6f994 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=B3=D0=BE=D1=80=D1=8C=20=D0=9D=D0=B0=D0=B4=D0=B5?= =?UTF-8?q?=D0=B8=D0=BD?= Date: Thu, 20 Nov 2025 18:52:29 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20=D0=B0=D0=B2=D1=82=D0=BE=D0=BC=D0=B0?= =?UTF-8?q?=D1=82=D0=B8=D1=87=D0=B5=D1=81=D0=BA=D0=BE=D0=B5=20=D0=BE=D0=B1?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20JWT=20=D1=82?= =?UTF-8?q?=D0=BE=D0=BA=D0=B5=D0=BD=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ApiClient теперь обрабатывает 401 и 403 ошибки для обновления токена - Добавлен JWTRefreshMiddleware для проактивного обновления токенов за 5 минут до истечения - Добавлена настройка JWT_REFRESH_THRESHOLD_MINUTES (по умолчанию 5) - Исправлена проблема с периодическими 403 ошибками после истечения access token --- backend/CHAT_LIST_FIXES.md | 209 ++++ backend/CHAT_LIST_UPDATES.md | 392 +++++++ backend/NOTIFICATION_COMPLETE_FINAL.md | 739 +++++++++++++ backend/NOTIFICATION_STAGE1_COMPLETE.md | 427 ++++++++ backend/NOTIFICATION_STAGE4_COMPLETE.md | 442 ++++++++ backend/NOTIFICATION_SYSTEM_PLAN.md | 978 ++++++++++++++++++ backend/TESTING_GUIDE.md | 270 +++++ backend/api/client.py | 5 +- backend/api/middleware.py | 63 ++ backend/api/urls.py | 1 + backend/api/v1/requests_app/views.py | 91 +- backend/calendar_app/apps.py | 1 + backend/calendar_app/notification_signals.py | 214 ++++ backend/check_pagination.py | 46 + .../MESSENGER_IMPLEMENTATION_COMPLETE.md | 345 ++++++ .../communications/MESSENGER_IMPROVEMENTS.md | 865 ++++++++++++++++ backend/communications/admin.py | 144 ++- backend/communications/api_views.py | 513 +++++++++ backend/communications/apps.py | 2 + backend/communications/consumers.py | 377 ++++++- ...at_created_by_chat_description_and_more.py | 41 + .../migrations/0007_alter_chat_type.py | 18 + .../migrations/0008_chatusersettings.py | 37 + ..._deleted_at_message_deleted_by_and_more.py | 131 +++ .../migrations/0010_messageattachment.py | 34 + ...esspermission_crosschatmessage_and_more.py | 95 ++ ...ership_chatreadstate_is_typing_and_more.py | 94 ++ backend/communications/models.py | 664 +++++++++++- .../communications/notification_signals.py | 219 ++++ backend/communications/urls.py | 94 +- backend/documents/apps.py | 1 + backend/documents/notification_signals.py | 151 +++ backend/documents/views.py | 14 + backend/employees/views_front.py | 33 + backend/eusrr_backend/asgi.py | 8 +- backend/eusrr_backend/settings.py | 6 + backend/eusrr_backend/urls.py | 1 + backend/feed/apps.py | 4 + backend/feed/notification_signals.py | 182 ++++ backend/feed/views_front.py | 59 +- backend/generate_notification.py | 197 ++++ backend/notifications/__init__.py | 0 backend/notifications/admin.py | 278 +++++ backend/notifications/api_urls.py | 36 + backend/notifications/api_views.py | 300 ++++++ backend/notifications/apps.py | 10 + backend/notifications/consumers.py | 119 +++ backend/notifications/management/__init__.py | 1 + .../management/commands/__init__.py | 1 + .../commands/create_notification_types.py | 561 ++++++++++ .../notifications/migrations/0001_initial.py | 146 +++ backend/notifications/migrations/__init__.py | 0 backend/notifications/models.py | 414 ++++++++ backend/notifications/routing.py | 6 + backend/notifications/services.py | 262 +++++ backend/notifications/signals.py | 2 + backend/notifications/test_views.py | 30 + backend/notifications/tests.py | 3 + backend/notifications/urls.py | 10 + backend/notifications/views.py | 15 + backend/quick_test.py | 108 ++ backend/requests_app/apps.py | 4 + backend/requests_app/notification_signals.py | 227 ++++ .../static/css/components/chat-enhanced.css | 301 ++++++ .../css/components/chat-list-enhanced.css | 133 +++ backend/static/css/components/list-view.css | 51 +- backend/static/css/components/navbar.css | 40 + backend/static/css/components/page-header.css | 13 + .../css/notifications/notifications.css | 425 ++++++++ backend/static/img/logo.png | Bin 81044 -> 375429 bytes backend/static/js/chat-detail-enhanced.js | 475 +++++++++ backend/static/js/chat-list-enhanced.js | 480 +++++++++ .../js/components/recipientPickerHandler.js | 35 + backend/static/js/navbar-mobile-search.js | 156 +++ .../js/notifications/notification-list.js | 448 ++++++++ .../js/notifications/notification-manager.js | 583 +++++++++++ .../js/notifications/notification-settings.js | 274 +++++ backend/templates/base.html | 4 + .../templates/communications/_filters.html | 23 + .../templates/communications/chat_list.html | 506 ++++++++- backend/templates/documents/_filters.html | 26 + .../templates/documents/document_list.html | 4 +- .../templates/employees/department_list.html | 30 +- .../templates/employees/employees_list.html | 36 +- .../employees/employees_list_NEW_EXAMPLE.html | 1 - backend/templates/feed/feed_list.html | 23 +- .../includes/components/page_header.html | 14 - backend/templates/includes/navbar.html | 102 +- .../notifications/notification_list.html | 76 ++ .../notifications/notification_list_new.html | 83 ++ .../notifications/notification_settings.html | 94 ++ .../notification_settings_new.html | 108 ++ backend/templates/requests_app/_filters.html | 20 +- .../requests_app/request_list_full.html | 22 +- backend/templates/search/_filters.html | 24 + backend/templates/search/results.html | 92 +- backend/test_all_signals.py | 285 +++++ backend/test_notification_create.py | 43 + backend/test_notification_debug.py | 95 ++ backend/test_notification_signals.py | 428 ++++++++ backend/test_pagination.py | 106 ++ test_notifications.py | 72 ++ 102 files changed, 16143 insertions(+), 328 deletions(-) create mode 100644 backend/CHAT_LIST_FIXES.md create mode 100644 backend/CHAT_LIST_UPDATES.md create mode 100644 backend/NOTIFICATION_COMPLETE_FINAL.md create mode 100644 backend/NOTIFICATION_STAGE1_COMPLETE.md create mode 100644 backend/NOTIFICATION_STAGE4_COMPLETE.md create mode 100644 backend/NOTIFICATION_SYSTEM_PLAN.md create mode 100644 backend/TESTING_GUIDE.md create mode 100644 backend/api/middleware.py create mode 100644 backend/calendar_app/notification_signals.py create mode 100644 backend/check_pagination.py create mode 100644 backend/communications/MESSENGER_IMPLEMENTATION_COMPLETE.md create mode 100644 backend/communications/MESSENGER_IMPROVEMENTS.md create mode 100644 backend/communications/api_views.py create mode 100644 backend/communications/migrations/0006_chat_avatar_chat_created_by_chat_description_and_more.py create mode 100644 backend/communications/migrations/0007_alter_chat_type.py create mode 100644 backend/communications/migrations/0008_chatusersettings.py create mode 100644 backend/communications/migrations/0009_message_deleted_at_message_deleted_by_and_more.py create mode 100644 backend/communications/migrations/0010_messageattachment.py create mode 100644 backend/communications/migrations/0011_chataccesspermission_crosschatmessage_and_more.py create mode 100644 backend/communications/migrations/0012_chatmembership_chatreadstate_is_typing_and_more.py create mode 100644 backend/communications/notification_signals.py create mode 100644 backend/documents/notification_signals.py create mode 100644 backend/feed/notification_signals.py create mode 100644 backend/generate_notification.py create mode 100644 backend/notifications/__init__.py create mode 100644 backend/notifications/admin.py create mode 100644 backend/notifications/api_urls.py create mode 100644 backend/notifications/api_views.py create mode 100644 backend/notifications/apps.py create mode 100644 backend/notifications/consumers.py create mode 100644 backend/notifications/management/__init__.py create mode 100644 backend/notifications/management/commands/__init__.py create mode 100644 backend/notifications/management/commands/create_notification_types.py create mode 100644 backend/notifications/migrations/0001_initial.py create mode 100644 backend/notifications/migrations/__init__.py create mode 100644 backend/notifications/models.py create mode 100644 backend/notifications/routing.py create mode 100644 backend/notifications/services.py create mode 100644 backend/notifications/signals.py create mode 100644 backend/notifications/test_views.py create mode 100644 backend/notifications/tests.py create mode 100644 backend/notifications/urls.py create mode 100644 backend/notifications/views.py create mode 100644 backend/quick_test.py create mode 100644 backend/requests_app/notification_signals.py create mode 100644 backend/static/css/components/chat-enhanced.css create mode 100644 backend/static/css/components/chat-list-enhanced.css create mode 100644 backend/static/css/notifications/notifications.css create mode 100644 backend/static/js/chat-detail-enhanced.js create mode 100644 backend/static/js/chat-list-enhanced.js create mode 100644 backend/static/js/navbar-mobile-search.js create mode 100644 backend/static/js/notifications/notification-list.js create mode 100644 backend/static/js/notifications/notification-manager.js create mode 100644 backend/static/js/notifications/notification-settings.js create mode 100644 backend/templates/communications/_filters.html create mode 100644 backend/templates/documents/_filters.html create mode 100644 backend/templates/notifications/notification_list.html create mode 100644 backend/templates/notifications/notification_list_new.html create mode 100644 backend/templates/notifications/notification_settings.html create mode 100644 backend/templates/notifications/notification_settings_new.html create mode 100644 backend/templates/search/_filters.html create mode 100644 backend/test_all_signals.py create mode 100644 backend/test_notification_create.py create mode 100644 backend/test_notification_debug.py create mode 100644 backend/test_notification_signals.py create mode 100644 backend/test_pagination.py create mode 100644 test_notifications.py diff --git a/backend/CHAT_LIST_FIXES.md b/backend/CHAT_LIST_FIXES.md new file mode 100644 index 00000000..e76a3940 --- /dev/null +++ b/backend/CHAT_LIST_FIXES.md @@ -0,0 +1,209 @@ +# Исправления списка чатов + +## Дата: 20 ноября 2025 + +--- + +## Проблемы + +1. ❌ Код JavaScript отображался на странице +2. ❌ Дублирование обработчиков событий фильтрации +3. ❌ Ненужная секция "Закрепленные" (отдельная категория) +4. ❌ Фильтр не работал + +--- + +## Решение + +### 1. Убрана секция "Закрепленные" + +**Было:** +```django + +``` + +**Стало:** +- Секция удалена полностью +- Закрепленные чаты остаются внутри своих категорий (глобальный, отделы, личные, группы и т.д.) + +### 2. Исправлено дублирование JavaScript + +**Было:** +```javascript +// В одном месте +applyBtn?.addEventListener('click', applyTypeFilter); +resetBtn?.addEventListener('click', resetFilter); + + +// И второй раз ниже +if (chatTypeSelect) { + chatTypeSelect.addEventListener('change', applyTypeFilter); +} +if (applyBtn) { + applyBtn.addEventListener('click', applyTypeFilter); // ДУБЛЬ! +} +if (resetBtn) { + resetBtn.addEventListener('click', resetFilter); // ДУБЛЬ! +} +applyTypeFilter(); + +``` + +**Стало:** +```javascript +applyBtn?.addEventListener('click', applyTypeFilter); +resetBtn?.addEventListener('click', resetFilter); + +// Применяем фильтр при загрузке +applyTypeFilter(); + + +{# Подключаем chat-list-enhanced.js #} + +{% endblock %} +``` + +### 3. Убрана опция "Закрепленные" из фильтра + +**Было в `_filters.html`:** +```html + +``` + +**Стало:** +- Опция удалена +- Фильтр работает с типами: все, глобальный, отделы, личные, группы, каналы, объявления + +--- + +## Как работает закрепление + +### Визуальное выделение +Закрепленные чаты остаются в своих категориях, но **выделяются**: +- 🎨 Желтый фон (`background: #fffbeb`) +- 📌 Желтая левая граница (`border-left: 4px solid var(--bs-warning)`) +- 🏷️ Бейдж с иконкой булавки в правом верхнем углу + +### Сортировка +`chat-list-enhanced.js` при загрузке и при закреплении: +```javascript +function moveToPinnedSection(chatRow) { + const parent = chatRow.parentElement; + const firstUnpinned = Array.from(parent.children).find(row => + !row.classList.contains('pinned') + ); + + if (firstUnpinned) { + parent.insertBefore(chatRow, firstUnpinned); // Вставляем перед первым незакрепленным + } else { + parent.appendChild(chatRow); + } +} +``` +- Закрепленные чаты **перемещаются в начало** своей категории +- Незакрепленные остаются ниже + +### Пример структуры +``` +📁 Личные + 📌 Иван Иванов (закреплен) ← желтый фон, иконка булавки + 📌 Мария Петрова (закреплена) + 👤 Алексей Сидоров + 👤 Ольга Николаева + +📁 Группы + 📌 Отдел разработки (закреплена) + 👥 Проект X + 👥 HR обсуждения +``` + +--- + +## Контекстное меню + +Правый клик на чате → меню: +- 📌 **Закрепить** / Открепить +- 🔔 Уведомления вкл/выкл +- 👁️ Скрыть +- ✅ Отметить прочитанным + +**API запрос:** +```javascript +fetch(`/communications/api/chat/${chatId}/pin/`, { + method: 'POST', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + 'X-CSRFToken': csrfToken + }, + body: `pinned=${!isPinned}` +}) +``` + +--- + +## Проверка работы + +### 1. Открыть страницу чатов +``` +http://localhost:9000/communications/chats/ +``` + +### 2. Проверить фильтр +- Выбрать "Личные" → должны показаться только личные чаты +- Выбрать "Группы" → только группы +- Выбрать "Все" → все категории видны + +### 3. Проверить закрепление +- Правый клик на любом чате +- Выбрать "Закрепить" +- Чат должен: + - Получить желтый фон + - Переместиться в начало своей категории + - Показать бейдж с булавкой + +### 4. Проверить открепление +- Правый клик на закрепленном чате +- Выбрать "Открепить" +- Чат должен: + - Вернуть обычный фон + - Переместиться вниз категории + - Убрать бейдж + +--- + +## Файлы изменены + +1. ✅ `backend/templates/communications/chat_list.html` + - Убрана секция `#pinnedSection` + - Исправлено дублирование JavaScript + - Добавлен вызов `applyTypeFilter()` при загрузке + +2. ✅ `backend/templates/communications/_filters.html` + - Убрана опция `