collab-appear
This commit is contained in:
@@ -1,10 +1,23 @@
|
||||
from datetime import datetime
|
||||
from base.orm import local_session
|
||||
from orm.collab import Collab
|
||||
from orm.shout import Shout
|
||||
from orm.user import User
|
||||
from base.resolvers import mutation
|
||||
from base.resolvers import query, mutation
|
||||
from auth.authenticate import login_required
|
||||
|
||||
@query.field("getCollabs")
|
||||
@login_required
|
||||
async def get_collabs(_, info):
|
||||
auth = info.context["request"].auth
|
||||
user_id = auth.user_id
|
||||
collabs = []
|
||||
with local_session() as session:
|
||||
user = session.query(User).where(User.id == user_id).first()
|
||||
collabs = session.query(Collab).filter(user.slug in Collab.authors)
|
||||
return collabs
|
||||
|
||||
|
||||
@mutation.field("inviteAuthor")
|
||||
@login_required
|
||||
async def invite_author(_, info, author, shout):
|
||||
@@ -23,7 +36,7 @@ async def invite_author(_, info, author, shout):
|
||||
return {"error": "already added"}
|
||||
shout.authors.append(author)
|
||||
shout.updated_at = datetime.now()
|
||||
shout.save()
|
||||
shout.save()
|
||||
session.commit()
|
||||
|
||||
# TODO: email notify
|
||||
@@ -48,7 +61,7 @@ async def remove_author(_, info, author, shout):
|
||||
return {"error": "not in authors"}
|
||||
shout.authors.remove(author)
|
||||
shout.updated_at = datetime.now()
|
||||
shout.save()
|
||||
shout.save()
|
||||
session.commit()
|
||||
|
||||
# result = Result("INVITED")
|
||||
|
Reference in New Issue
Block a user