This commit is contained in:
parent
47ecf4bd1a
commit
c6df11dc7d
|
@ -1,3 +1,4 @@
|
|||
import logging
|
||||
import time
|
||||
|
||||
from sqlalchemy import and_, select
|
||||
|
@ -17,6 +18,10 @@ from services.schema import mutation, query
|
|||
from services.search import search_service
|
||||
|
||||
|
||||
logger = logging.getLogger('[resolver.editor]')
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
|
||||
@query.field('get_shouts_drafts')
|
||||
@login_required
|
||||
async def get_shouts_drafts(_, info):
|
||||
|
@ -160,14 +165,15 @@ def patch_topics(session, shout, topics_input):
|
|||
|
||||
@mutation.field('update_shout')
|
||||
@login_required
|
||||
async def update_shout(_, info, shout_id, shout_input=None, publish=False):
|
||||
async def update_shout(_, info, shout_input=None, publish=False):
|
||||
user_id = info.context['user_id']
|
||||
roles = info.context['roles']
|
||||
shout_input = shout_input or {}
|
||||
with local_session() as session:
|
||||
author = session.query(Author).filter(Author.user == user_id).first()
|
||||
current_time = int(time.time())
|
||||
if isinstance(author, Author):
|
||||
shout_id = shout_input.get('id')
|
||||
if isinstance(author, Author) and isinstance(shout_id, int):
|
||||
shout = (
|
||||
session.query(Shout)
|
||||
.options(
|
||||
|
@ -210,6 +216,8 @@ async def update_shout(_, info, shout_id, shout_input=None, publish=False):
|
|||
search_service.index(shout)
|
||||
|
||||
return {'shout': shout_dict}
|
||||
logger.debug(f' cannot update with data: {shout_input}')
|
||||
return { 'error': 'not enough data' }
|
||||
return {'error': 'cannot update'}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user