Skip to content

Commit

Permalink
feat(organisation): add approved filter to fetch all organisations
Browse files Browse the repository at this point in the history
  • Loading branch information
Anuj-Gupta4 committed Jan 6, 2025
1 parent 61c2610 commit 4e3f89f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/backend/app/db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ async def one(cls, db: Connection, org_identifier: int | str) -> Self:

@classmethod
async def all(
cls, db: Connection, current_user_id: int = 0
cls, db: Connection, current_user_id: int = 0, approved: Optional[bool] = True
) -> Optional[list[Self]]:
"""Fetch all organisations.
Expand All @@ -384,11 +384,12 @@ async def all(
THEN TRUE
ELSE approved
END = TRUE
AND approved = %(approved)s
ORDER BY created_at DESC;
"""

async with db.cursor(row_factory=class_row(cls)) as cur:
await cur.execute(sql, {"user_id": current_user_id})
await cur.execute(sql, {"user_id": current_user_id, "approved": approved})
return await cur.fetchall()

@classmethod
Expand Down

0 comments on commit 4e3f89f

Please sign in to comment.