This commit is contained in:
parent
18521f3fc5
commit
d3b2eddf58
|
@ -79,14 +79,16 @@ async def update_profile(_, info, profile):
|
||||||
Author.update(author, profile)
|
Author.update(author, profile)
|
||||||
session.add(author)
|
session.add(author)
|
||||||
session.commit()
|
session.commit()
|
||||||
return {'error': None, 'author': author}
|
return {'error': None, 'author': author}
|
||||||
|
|
||||||
|
|
||||||
# TODO: caching query
|
# TODO: caching query
|
||||||
@query.field('get_authors_all')
|
@query.field('get_authors_all')
|
||||||
async def get_authors_all(_, _info):
|
async def get_authors_all(_, _info):
|
||||||
|
authors = []
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
return session.query(Author).all()
|
authors = session.query(Author).all()
|
||||||
|
return authors
|
||||||
|
|
||||||
|
|
||||||
def count_author_comments_rating(session, author_id) -> int:
|
def count_author_comments_rating(session, author_id) -> int:
|
||||||
|
|
|
@ -21,6 +21,7 @@ from services.search import search_service
|
||||||
@login_required
|
@login_required
|
||||||
async def get_shouts_drafts(_, info):
|
async def get_shouts_drafts(_, info):
|
||||||
user_id = info.context['user_id']
|
user_id = info.context['user_id']
|
||||||
|
shouts = []
|
||||||
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()
|
||||||
if author:
|
if author:
|
||||||
|
@ -34,7 +35,7 @@ async def get_shouts_drafts(_, info):
|
||||||
.group_by(Shout.id)
|
.group_by(Shout.id)
|
||||||
)
|
)
|
||||||
shouts = [shout for [shout] in session.execute(q).unique()]
|
shouts = [shout for [shout] in session.execute(q).unique()]
|
||||||
return shouts
|
return shouts
|
||||||
|
|
||||||
|
|
||||||
@mutation.field('create_shout')
|
@mutation.field('create_shout')
|
||||||
|
@ -189,7 +190,7 @@ async def update_shout(_, info, shout_id, shout_input=None, publish=False):
|
||||||
# main topic
|
# main topic
|
||||||
main_topic = shout_input.get('main_topic')
|
main_topic = shout_input.get('main_topic')
|
||||||
if main_topic:
|
if main_topic:
|
||||||
patch_main_topic(main_topic)
|
patch_main_topic(session, main_topic, shout)
|
||||||
|
|
||||||
shout_input['updated_at'] = current_time
|
shout_input['updated_at'] = current_time
|
||||||
shout_input['published_at'] = current_time if publish else None
|
shout_input['published_at'] = current_time if publish else None
|
||||||
|
|
|
@ -109,11 +109,13 @@ async def get_topic(_, _info, slug):
|
||||||
async def create_topic(_, _info, inp):
|
async def create_topic(_, _info, inp):
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
# TODO: check user permissions to create topic for exact community
|
# TODO: check user permissions to create topic for exact community
|
||||||
|
# and actor is permitted to craete it
|
||||||
new_topic = Topic(**inp)
|
new_topic = Topic(**inp)
|
||||||
session.add(new_topic)
|
session.add(new_topic)
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
return {'topic': new_topic}
|
return {'topic': new_topic}
|
||||||
|
return {'error': 'cannot create topic'}
|
||||||
|
|
||||||
|
|
||||||
@mutation.field('update_topic')
|
@mutation.field('update_topic')
|
||||||
|
@ -130,6 +132,7 @@ async def update_topic(_, _info, inp):
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
return {'topic': topic}
|
return {'topic': topic}
|
||||||
|
return {'error': 'cannot update' }
|
||||||
|
|
||||||
|
|
||||||
@mutation.field('delete_topic')
|
@mutation.field('delete_topic')
|
||||||
|
@ -149,8 +152,7 @@ async def delete_topic(_, info, slug: str):
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
return {}
|
return {}
|
||||||
else:
|
return {'error': 'access denied'}
|
||||||
return {'error': 'access denied'}
|
|
||||||
|
|
||||||
|
|
||||||
def topic_follow(follower_id, slug):
|
def topic_follow(follower_id, slug):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user