patch-main-topic-fix
This commit is contained in:
parent
e378cbd442
commit
61088320c9
|
@ -38,7 +38,7 @@ async def get_my_shout(_, info, shout_id: int):
|
||||||
if 'editor' in roles or filter(
|
if 'editor' in roles or filter(
|
||||||
lambda x: x.id == author.id, [x for x in shout.authors]
|
lambda x: x.id == author.id, [x for x in shout.authors]
|
||||||
):
|
):
|
||||||
return {'error': error, 'shout': shout}
|
return {'error': None, 'shout': shout}
|
||||||
else:
|
else:
|
||||||
error = 'forbidden'
|
error = 'forbidden'
|
||||||
return {'error': error, 'shout': shout}
|
return {'error': error, 'shout': shout}
|
||||||
|
@ -134,6 +134,10 @@ async def create_shout(_, info, inp):
|
||||||
|
|
||||||
|
|
||||||
def patch_main_topic(session, main_topic, shout):
|
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 = (
|
old_main_topic = (
|
||||||
session.query(ShoutTopic)
|
session.query(ShoutTopic)
|
||||||
.filter(and_(ShoutTopic.shout == shout.id, ShoutTopic.main.is_(True)))
|
.filter(and_(ShoutTopic.shout == shout.id, ShoutTopic.main.is_(True)))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user