fix: various bugs + improve api readability

This commit is contained in:
swve 2023-11-29 21:59:35 +01:00
parent 7daf6df5a0
commit 2bf80030d7
21 changed files with 98 additions and 75 deletions

View file

@ -118,10 +118,11 @@ async def create_org(
async def update_org(
request: Request,
org_object: OrganizationUpdate,
org_id: int,
current_user: PublicUser | AnonymousUser,
db_session: Session,
):
statement = select(Organization).where(Organization.id == org_object.org_id)
statement = select(Organization).where(Organization.id == org_id)
result = db_session.exec(statement)
org = result.first()
@ -149,9 +150,6 @@ async def update_org(
detail="Organization slug already exists",
)
# Remove the org_id from the org_object
del org_object.org_id
# Update only the fields that were passed in
for var, value in vars(org_object).items():
if value is not None:
@ -203,7 +201,6 @@ async def update_org_logo(
db_session.commit()
db_session.refresh(org)
return {"detail": "Logo updated"}