shout-id-fox+test-imports-fix
All checks were successful
Deploy on push / deploy (push) Successful in 6s

This commit is contained in:
Untone 2025-05-29 23:40:27 +03:00
parent e375db4125
commit 1223c1d278
7 changed files with 10 additions and 7 deletions

View File

@ -7,6 +7,9 @@
- Интеграция с функцией `get_with_stat` для единого подхода к получению статистики - Интеграция с функцией `get_with_stat` для единого подхода к получению статистики
### Исправлено ### Исправлено
- Ошибка "'dict' object has no attribute 'id'" в функции `load_shouts_search`:
- Исправлен доступ к атрибуту `id` у объектов shout, которые возвращаются как словари из `get_shouts_with_links`
- Заменен `shout.id` на `shout["id"]` и `shout.score` на `shout["score"]` в функции поиска публикаций
- Ошибка в функции `unpublish_shout`: - Ошибка в функции `unpublish_shout`:
- Исправлена проверка наличия связанного черновика: `if shout.draft is not None` - Исправлена проверка наличия связанного черновика: `if shout.draft is not None`
- Правильное получение черновика через его ID с загрузкой связей - Правильное получение черновика через его ID с загрузкой связей

View File

@ -306,7 +306,7 @@ async def create_article_example(request: Request): # Используем Reque
""" """
user: Author = request.user # request.user добавляется декоратором @login_required user: Author = request.user # request.user добавляется декоратором @login_required
# Проверяем право на создание статей (метод из модели auth.orm.Author) # Проверяем право на создание статей (метод из модели auth.auth.orm)
if not user.has_permission('articles', 'create'): if not user.has_permission('articles', 'create'):
return JSONResponse({'error': 'Недостаточно прав для создания статьи'}, status_code=403) return JSONResponse({'error': 'Недостаточно прав для создания статьи'}, status_code=403)

View File

@ -473,8 +473,8 @@ async def load_shouts_search(_, info, text, options):
q = apply_sorting(q, options) q = apply_sorting(q, options)
shouts = get_shouts_with_links(info, q, limit, offset) shouts = get_shouts_with_links(info, q, limit, offset)
for shout in shouts: for shout in shouts:
shout.score = scores[f"{shout.id}"] shout["score"] = scores[f"{shout['id']}"]
shouts.sort(key=lambda x: x.score, reverse=True) shouts.sort(key=lambda x: x["score"], reverse=True)
return shouts return shouts
return [] return []

View File

@ -1,7 +1,7 @@
from dataclasses import dataclass from dataclasses import dataclass
from typing import List, Optional from typing import List, Optional
from orm.author import Author from auth.orm import Author
from orm.community import Community from orm.community import Community
from orm.reaction import Reaction from orm.reaction import Reaction
from orm.shout import Shout from orm.shout import Shout

View File

@ -1,6 +1,6 @@
import pytest import pytest
from orm.author import Author from auth.orm import Author
from orm.shout import Shout from orm.shout import Shout

View File

@ -2,7 +2,7 @@ from datetime import datetime
import pytest import pytest
from orm.author import Author from auth.orm import Author
from orm.reaction import ReactionKind from orm.reaction import ReactionKind
from orm.shout import Shout from orm.shout import Shout

View File

@ -2,7 +2,7 @@ from datetime import datetime
import pytest import pytest
from orm.author import Author from auth.orm import Author
from orm.shout import Shout from orm.shout import Shout