This commit is contained in:
parent
130942d9dd
commit
12a9880815
|
@ -175,12 +175,12 @@ def patch_topics(session, shout, topics_input):
|
||||||
@mutation.field('update_shout')
|
@mutation.field('update_shout')
|
||||||
@login_required
|
@login_required
|
||||||
async def update_shout(_, info, shout_id, shout_input=None, publish=False):
|
async def update_shout(_, info, shout_id, shout_input=None, publish=False):
|
||||||
try:
|
|
||||||
user_id = info.context.get('user_id')
|
user_id = info.context.get('user_id')
|
||||||
if not user_id:
|
|
||||||
return {"error": "unauthorized"}
|
|
||||||
roles = info.context.get('roles', [])
|
roles = info.context.get('roles', [])
|
||||||
shout_input = shout_input or {}
|
shout_input = shout_input or {}
|
||||||
|
if not user_id:
|
||||||
|
return {"error": "unauthorized"}
|
||||||
|
try:
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
author = session.query(Author).filter(Author.user == user_id).first()
|
author = session.query(Author).filter(Author.user == user_id).first()
|
||||||
current_time = int(time.time())
|
current_time = int(time.time())
|
||||||
|
@ -206,7 +206,7 @@ async def update_shout(_, info, shout_id, shout_input=None, publish=False):
|
||||||
)
|
)
|
||||||
shout_input['slug'] = slug
|
shout_input['slug'] = slug
|
||||||
|
|
||||||
if isinstance(author, Author) and isinstance(shout_id, int):
|
if author and isinstance(shout_id, int):
|
||||||
shout = (
|
shout = (
|
||||||
session.query(Shout)
|
session.query(Shout)
|
||||||
.options(joinedload(Shout.authors), joinedload(Shout.topics))
|
.options(joinedload(Shout.authors), joinedload(Shout.topics))
|
||||||
|
|
|
@ -229,6 +229,7 @@ async def load_shouts_by(_, _info, options):
|
||||||
|
|
||||||
return shouts
|
return shouts
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@query.field('load_shouts_drafts')
|
@query.field('load_shouts_drafts')
|
||||||
async def load_shouts_drafts(_, info):
|
async def load_shouts_drafts(_, info):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user