feat: add courses index page + backend update

This commit is contained in:
swve 2022-10-01 10:16:35 +02:00
parent 86fdd89b23
commit 4b623ae1b8
14 changed files with 218 additions and 50 deletions

View file

@ -22,6 +22,13 @@ class OrganizationInDB(Organization):
org_id: str
owners: List[str]
admins: List[str]
class PublicOrganization(Organization):
name: str
description: str
email: str
slug: str
org_id: str
#### Classes ####################################################
@ -37,7 +44,20 @@ async def get_organization(org_id: str):
raise HTTPException(
status_code=status.HTTP_409_CONFLICT, detail="Organization does not exist")
org = Organization(**org)
org = PublicOrganization(**org)
return org
async def get_organization_by_slug(org_slug: str):
await check_database()
orgs = learnhouseDB["organizations"]
org = orgs.find_one({"slug": org_slug})
if not org:
raise HTTPException(
status_code=status.HTTP_409_CONFLICT, detail="Organization does not exist")
org = PublicOrganization(**org)
return org