wip: org to community
This commit is contained in:
parent
85f697addd
commit
9721bd41d5
|
@ -1,4 +1,4 @@
|
||||||
from orm.rbac import Organization, Operation, Resource, Permission, Role
|
from orm.rbac import Community, Operation, Resource, Permission, Role
|
||||||
from orm.user import User
|
from orm.user import User
|
||||||
from orm.message import Message
|
from orm.message import Message
|
||||||
from orm.topic import Topic
|
from orm.topic import Topic
|
||||||
|
|
|
@ -11,7 +11,7 @@ class Community(Base):
|
||||||
slug: str = Column(String, unique = True, nullable = False)
|
slug: str = Column(String, unique = True, nullable = False)
|
||||||
desc: str = Column(String, nullable=False, default='')
|
desc: str = Column(String, nullable=False, default='')
|
||||||
pic: str = Column(String, nullable=False, default='')
|
pic: str = Column(String, nullable=False, default='')
|
||||||
org_id: str = Column(ForeignKey("organization.id"), nullable=True)
|
# org_id: str = Column(ForeignKey("organization.id"), nullable=True)
|
||||||
createdAt: str = Column(DateTime, nullable=False, default = datetime.now, comment="Created at")
|
createdAt: str = Column(DateTime, nullable=False, default = datetime.now, comment="Created at")
|
||||||
createdBy: str = Column(ForeignKey("user.id"), nullable=False, comment="Creator")
|
createdBy: str = Column(ForeignKey("user.id"), nullable=False, comment="Creator")
|
||||||
|
|
|
@ -33,7 +33,7 @@ class Role(Base):
|
||||||
# id is auto field
|
# id is auto field
|
||||||
|
|
||||||
name: str = Column(String, nullable=False, comment="Role Name")
|
name: str = Column(String, nullable=False, comment="Role Name")
|
||||||
desc: str = Colulm(String, nullable=True, comment="Role Description")
|
desc: str = Column(String, nullable=True, comment="Role Description")
|
||||||
community: int = Column(ForeignKey("community.id", ondelete="CASCADE"), nullable=False, comment="Community")
|
community: int = Column(ForeignKey("community.id", ondelete="CASCADE"), nullable=False, comment="Community")
|
||||||
permissions = relationship(lambda: Permission)
|
permissions = relationship(lambda: Permission)
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from orm import Shout, User, Organization, Resource
|
from orm import Shout, User, Community, Resource
|
||||||
from orm.base import local_session
|
from orm.base import local_session
|
||||||
|
|
||||||
from resolvers.base import mutation, query
|
from resolvers.base import mutation, query
|
||||||
|
@ -18,7 +18,7 @@ class GitTask:
|
||||||
def __init__(self, input, org, username, user_email, comment):
|
def __init__(self, input, org, username, user_email, comment):
|
||||||
self.slug = input["slug"];
|
self.slug = input["slug"];
|
||||||
self.shout_body = input["body"];
|
self.shout_body = input["body"];
|
||||||
self.org = org;
|
self.org = org; #FIXME
|
||||||
self.username = username;
|
self.username = username;
|
||||||
self.user_email = user_email;
|
self.user_email = user_email;
|
||||||
self.comment = comment;
|
self.comment = comment;
|
||||||
|
@ -84,19 +84,14 @@ async def create_shout(_, info, input):
|
||||||
auth = info.context["request"].auth
|
auth = info.context["request"].auth
|
||||||
user_id = auth.user_id
|
user_id = auth.user_id
|
||||||
|
|
||||||
org_id = org = input["org_id"]
|
# org_id = org = input["org_id"]
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
user = session.query(User).filter(User.id == user_id).first()
|
user = session.query(User).filter(User.id == user_id).first()
|
||||||
org = session.query(Organization).filter(Organization.id == org_id).first()
|
# org = session.query(Organization).filter(Organization.id == org_id).first()
|
||||||
|
|
||||||
if not org:
|
|
||||||
return {
|
|
||||||
"error" : "invalid organization"
|
|
||||||
}
|
|
||||||
|
|
||||||
new_shout = Shout.create(
|
new_shout = Shout.create(
|
||||||
slug = input["slug"],
|
slug = input["slug"],
|
||||||
org_id = org_id,
|
# org_id = org_id,
|
||||||
authors = [user_id, ],
|
authors = [user_id, ],
|
||||||
body = input["body"],
|
body = input["body"],
|
||||||
replyTo = input.get("replyTo"),
|
replyTo = input.get("replyTo"),
|
||||||
|
@ -124,11 +119,11 @@ async def update_shout(_, info, input):
|
||||||
user_id = auth.user_id
|
user_id = auth.user_id
|
||||||
|
|
||||||
slug = input["slug"]
|
slug = input["slug"]
|
||||||
org_id = org = input["org_id"]
|
# org_id = org = input["org_id"]
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
user = session.query(User).filter(User.id == user_id).first()
|
user = session.query(User).filter(User.id == user_id).first()
|
||||||
shout = session.query(Shout).filter(Shout.slug == slug).first()
|
shout = session.query(Shout).filter(Shout.slug == slug).first()
|
||||||
org = session.query(Organization).filter(Organization.id == org_id).first()
|
# org = session.query(Organization).filter(Organization.id == org_id).first()
|
||||||
|
|
||||||
if not shout:
|
if not shout:
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user