diff --git a/apps/api/src/admin/participant_manager.py b/apps/api/src/admin/participant_manager.py index b7d69e21..3495b8d6 100644 --- a/apps/api/src/admin/participant_manager.py +++ b/apps/api/src/admin/participant_manager.py @@ -9,13 +9,21 @@ log = getLogger(__name__) +NON_HACKER_ROLES = ( + Role.MENTOR, + Role.VOLUNTEER, + Role.SPONSOR, + Role.JUDGE, + Role.WORKSHOP_LEAD, +) + class Participant(UserRecord): """Participants attending the event.""" first_name: str last_name: str - status: Union[Status, Decision] + status: Union[Status, Decision] = Status.REVIEWED async def get_hackers() -> list[Participant]: @@ -47,6 +55,16 @@ async def get_hackers() -> list[Participant]: return [Participant(**user, **user["application_data"]) for user in records] +async def get_non_hackers() -> list[Participant]: + """Fetch all non-hackers participating in the event.""" + records: list[dict[str, Any]] = await mongodb_handler.retrieve( + Collection.USERS, + {"role": {"$in": NON_HACKER_ROLES}}, + ["_id", "status", "role", "first_name", "last_name"], + ) + return [Participant(**user) for user in records] + + async def check_in_participant(uid: str, associate: User) -> None: """Check in participant at IrvineHacks""" record: Optional[dict[str, object]] = await mongodb_handler.retrieve_one( @@ -76,20 +94,12 @@ async def check_in_participant(uid: str, associate: User) -> None: async def confirm_attendance_non_hacker(uid: str, director: User) -> None: """Update status for Role.Attending for non-hackers.""" - allowed_roles = ( - Role.MENTOR, - Role.ORGANIZER, - Role.VOLUNTEER, - Role.SPONSOR, - Role.JUDGE, - Role.WORKSHOP_LEAD, - ) record: Optional[dict[str, object]] = await mongodb_handler.retrieve_one( Collection.USERS, {"_id": uid, "status": Status.WAIVER_SIGNED} ) - if not record or record["role"] not in allowed_roles: + if not record or record["role"] not in NON_HACKER_ROLES: raise ValueError update_status = await mongodb_handler.raw_update_one( diff --git a/apps/api/src/routers/admin.py b/apps/api/src/routers/admin.py index b757c64f..0b754e85 100644 --- a/apps/api/src/routers/admin.py +++ b/apps/api/src/routers/admin.py @@ -248,8 +248,9 @@ async def waitlist_release(uid: str) -> None: @router.get("/participants", dependencies=[Depends(require_checkin_associate)]) async def participants() -> list[Participant]: """Get list of participants.""" - # TODO: non-hackers - return await participant_manager.get_hackers() + hackers = await participant_manager.get_hackers() + non_hackers = await participant_manager.get_non_hackers() + return hackers + non_hackers @router.post("/checkin/{uid}")