collab-appear
This commit is contained in:
parent
fe13488584
commit
85892a88bc
22
orm/collab.py
Normal file
22
orm/collab.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
from datetime import datetime
|
||||
from sqlalchemy import Boolean, Column, String, ForeignKey, DateTime
|
||||
from base.orm import Base
|
||||
|
||||
class CollabAuthor(Base):
|
||||
__tablename__ = 'collab_author'
|
||||
|
||||
id = None
|
||||
collab = Column(ForeignKey('collab.id'), primary_key = True)
|
||||
author = Column(ForeignKey('user.slug'), primary_key = True)
|
||||
accepted = Column(Boolean, default=False)
|
||||
|
||||
class Collab(Base):
|
||||
__tablename__ = 'collab'
|
||||
|
||||
authors = Column()
|
||||
title: str = Column(String, nullable=True, comment="Title")
|
||||
body: str = Column(String, nullable=True, comment="Body")
|
||||
pic: str = Column(String, nullable=True, comment="Picture")
|
||||
createdAt: datetime = Column(DateTime, default=datetime.now, comment="Created At")
|
||||
createdBy: str = Column(ForeignKey('user.id'), comment="Created By")
|
||||
|
|
@ -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):
|
||||
|
|
|
@ -245,8 +245,7 @@ type Query {
|
|||
reactionsForSlugs(slugs: [String]!, page: Int!, size: Int!): [Reaction]!
|
||||
|
||||
# collab
|
||||
inviteAuthor(slug: String!, author: String!): Result!
|
||||
removeAuthor(slug: String!, author: String!): Result
|
||||
getCollabs: [Collab]!
|
||||
|
||||
# topics
|
||||
topicsAll(page: Int!, size: Int!): [Topic]!
|
||||
|
@ -339,6 +338,14 @@ type User {
|
|||
oid: String
|
||||
}
|
||||
|
||||
type Collab {
|
||||
authors: [String]!
|
||||
invites: [String]
|
||||
createdAt: DateTime!
|
||||
title: String
|
||||
body: String
|
||||
}
|
||||
|
||||
enum ReactionKind {
|
||||
LIKE
|
||||
DISLIKE
|
||||
|
@ -392,7 +399,7 @@ type Shout {
|
|||
body: String!
|
||||
createdAt: DateTime!
|
||||
authors: [Author]
|
||||
# ratings: [Rating]
|
||||
lang: String
|
||||
community: String
|
||||
cover: String
|
||||
layout: String
|
||||
|
|
Loading…
Reference in New Issue
Block a user