This commit is contained in:
parent
2db1da3194
commit
582ba75643
|
@ -461,8 +461,35 @@ async def update_shout(_, info, shout_id: int, shout_input=None, publish=False):
|
||||||
for a in shout_by_id.authors:
|
for a in shout_by_id.authors:
|
||||||
await cache_by_id(Author, a.id, cache_author)
|
await cache_by_id(Author, a.id, cache_author)
|
||||||
logger.info(f"shout#{shout_id} updated")
|
logger.info(f"shout#{shout_id} updated")
|
||||||
shout_dict = shout_by_id.dict()
|
# Получаем полные данные шаута со связями
|
||||||
logger.info(f"Final shout data: {shout_dict}") # Добавляем лог финальных данных
|
shout_with_relations = (
|
||||||
|
session.query(Shout)
|
||||||
|
.options(joinedload(Shout.topics), joinedload(Shout.authors))
|
||||||
|
.filter(Shout.id == shout_id)
|
||||||
|
.first()
|
||||||
|
)
|
||||||
|
|
||||||
|
shout_dict = shout_with_relations.dict()
|
||||||
|
# Явно добавляем связанные данные в словарь
|
||||||
|
shout_dict["topics"] = (
|
||||||
|
[
|
||||||
|
{"id": topic.id, "slug": topic.slug, "title": topic.title}
|
||||||
|
for topic in shout_with_relations.topics
|
||||||
|
]
|
||||||
|
if shout_with_relations.topics
|
||||||
|
else []
|
||||||
|
)
|
||||||
|
|
||||||
|
shout_dict["authors"] = (
|
||||||
|
[
|
||||||
|
{"id": author.id, "name": author.name, "slug": author.slug}
|
||||||
|
for author in shout_with_relations.authors
|
||||||
|
]
|
||||||
|
if shout_with_relations.authors
|
||||||
|
else []
|
||||||
|
)
|
||||||
|
|
||||||
|
logger.info(f"Final shout data with relations: {shout_dict}")
|
||||||
return {"shout": shout_dict, "error": None}
|
return {"shout": shout_dict, "error": None}
|
||||||
else:
|
else:
|
||||||
logger.warning(f"Access denied: author #{author_id} cannot edit shout#{shout_id}")
|
logger.warning(f"Access denied: author #{author_id} cannot edit shout#{shout_id}")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user