update-after-debug
This commit is contained in:
parent
818b4ccae9
commit
c346481ade
|
@ -23,13 +23,19 @@ from services.logger import root_logger as logger
|
||||||
@mutation.field('update_author')
|
@mutation.field('update_author')
|
||||||
@login_required
|
@login_required
|
||||||
async def update_author(_, info, profile):
|
async def update_author(_, info, profile):
|
||||||
user_id = info.context['user_id']
|
user_id = info.context.get('user_id')
|
||||||
with local_session() as session:
|
if not user_id:
|
||||||
author = session.query(Author).where(Author.user == user_id).first()
|
return {'error': 'unauthorized', 'author': None}
|
||||||
Author.update(author, profile)
|
try:
|
||||||
session.add(author)
|
with local_session() as session:
|
||||||
session.commit()
|
author = session.query(Author).where(Author.user == user_id).first()
|
||||||
return {'error': None, 'author': author}
|
if author:
|
||||||
|
Author.update(author, profile)
|
||||||
|
session.add(author)
|
||||||
|
session.commit()
|
||||||
|
return {'error': None, 'author': author}
|
||||||
|
except Exception as exc:
|
||||||
|
return {'error': exc, 'author': None}
|
||||||
|
|
||||||
|
|
||||||
@query.field('get_authors_all')
|
@query.field('get_authors_all')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user