mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: add new fancy index + add org slugs
This commit is contained in:
parent
1b3df392b7
commit
86fdd89b23
11 changed files with 376 additions and 21 deletions
|
|
@ -15,6 +15,7 @@ class Organization(BaseModel):
|
|||
name: str
|
||||
description: str
|
||||
email: str
|
||||
slug :str
|
||||
|
||||
|
||||
class OrganizationInDB(Organization):
|
||||
|
|
@ -45,11 +46,11 @@ async def create_org(org_object: Organization, current_user: User):
|
|||
orgs = learnhouseDB["organizations"]
|
||||
|
||||
# find if org already exists using name
|
||||
isOrgAvailable = orgs.find_one({"name": org_object.name})
|
||||
isOrgAvailable = orgs.find_one({"slug": org_object.slug})
|
||||
|
||||
if isOrgAvailable:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_409_CONFLICT, detail="Organization name already exists")
|
||||
status_code=status.HTTP_409_CONFLICT, detail="Organization slug already exists")
|
||||
|
||||
# generate org_id with uuid4
|
||||
org_id = str(f"org_{uuid4()}")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue