mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: change organization schema
This commit is contained in:
parent
dee9ae6cf3
commit
ae280b2cfb
1 changed files with 6 additions and 9 deletions
|
|
@ -16,12 +16,11 @@ class Organization(BaseModel):
|
|||
description: str
|
||||
email: str
|
||||
slug: str
|
||||
default: bool
|
||||
|
||||
|
||||
class OrganizationInDB(Organization):
|
||||
org_id: str
|
||||
owners: List[str]
|
||||
admins: List[str]
|
||||
|
||||
|
||||
class PublicOrganization(Organization):
|
||||
|
|
@ -75,9 +74,7 @@ async def create_org(request: Request, org_object: Organization, current_user: P
|
|||
# generate org_id with uuid4
|
||||
org_id = str(f"org_{uuid4()}")
|
||||
|
||||
org = OrganizationInDB(org_id=org_id, owners=[
|
||||
current_user.user_id], admins=[
|
||||
current_user.user_id], **org_object.dict())
|
||||
org = OrganizationInDB(org_id=org_id, **org_object.dict())
|
||||
|
||||
org_in_db = await orgs.insert_one(org.dict())
|
||||
|
||||
|
|
@ -113,7 +110,7 @@ async def update_org(request: Request, org_object: Organization, org_id: str, cu
|
|||
status_code=status.HTTP_409_CONFLICT, detail="Organization does not exist")
|
||||
|
||||
updated_org = OrganizationInDB(
|
||||
org_id=org_id, owners=owners, admins=admins, **org_object.dict())
|
||||
org_id=org_id, **org_object.dict())
|
||||
|
||||
await orgs.update_one({"org_id": org_id}, {"$set": updated_org.dict()})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue