refactor(communications): переименование viewsets.py в views.py

Структурная реорганизация:
- Удален legacy views.py (оставалась только get_available_reactions)
- Переименован viewsets.py → views.py (теперь основной модуль)
- ViewSets теперь в стандартном location (views.py)

Обновлены импорты:
- api/v1/urls.py: from .communications.views import ViewSets
- Удален неиспользуемый endpoint: communications/reactions/available/

Удалено legacy FBV (было 18 функций):
- get_user_chats() → ChatViewSet.list()
- upload_message_with_attachments() → MessageViewSet.upload()
- load_chat_messages() → ChatViewSet.messages()
- load_chat_messages_around() → ChatViewSet.messages_around()
- add_reaction() → MessageViewSet.react()
- remove_reaction() → MessageViewSet.unreact()
- pin_chat() → ChatViewSet.pin()
- toggle_chat_notifications() → ChatViewSet.notifications()
- forward_messages() → MessageViewSet.forward()
- bulk_delete_messages() → MessageViewSet.bulk_delete()
- edit_message() → MessageViewSet.update()
- delete_message() → MessageViewSet.destroy()
- create_chat() → ChatViewSet.create()
- get_available_reactions() → удалена (не используется)

Итоги:
- Удалено 1,722 строк дублирующего кода (-56%)
- 100% переход на ViewSets
- Соответствие DRF best practices

Ref: docs/completed/LEGACY_CODE_CLEANUP.md
This commit is contained in:
Игорь Надеин 2026-01-15 12:16:15 +03:00
parent ba4a7f1eb9
commit 3f5781cd52
3 changed files with 1005 additions and 2326 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -11,11 +11,8 @@ from .feed.views import CommentViewSet, PostViewSet
from .documents.views import DocumentViewSet
from .requests_app.views import RequestViewSet
# NEW: Импорт ViewSets для Communications
from .communications.viewsets import ChatViewSet, MessageViewSet, PollViewSet
# OLD: Function-based views (постепенно удалим)
from .communications.views import get_available_reactions
# Communications ViewSets
from .communications.views import ChatViewSet, MessageViewSet, PollViewSet
app_name = "v1"
@ -64,13 +61,6 @@ urlpatterns = [
name="verify-email",
),
# Communications: доступные реакции (для обратной совместимости)
path(
"communications/reactions/available/",
get_available_reactions,
name="available_reactions"
),
# Notifications API
path("notifications/", include("api.v1.notifications.urls")),