patch-main-topic-fix

This commit is contained in:
Untone 2024-03-07 11:55:23 +03:00
parent e378cbd442
commit 61088320c9

View File

@ -38,7 +38,7 @@ async def get_my_shout(_, info, shout_id: int):
if 'editor' in roles or filter(
lambda x: x.id == author.id, [x for x in shout.authors]
):
return {'error': error, 'shout': shout}
return {'error': None, 'shout': shout}
else:
error = 'forbidden'
return {'error': error, 'shout': shout}
@ -134,6 +134,10 @@ async def create_shout(_, info, inp):
def patch_main_topic(session, main_topic, shout):
with session.begin():
shout = session.query(Shout).options(joinedload(Shout.topics)).filter(Shout.id == shout.id).first()
if not shout:
return
old_main_topic = (
session.query(ShoutTopic)
.filter(and_(ShoutTopic.shout == shout.id, ShoutTopic.main.is_(True)))