From dbc6f4a09731e54c08973b257a1c25d4cb73b712 Mon Sep 17 00:00:00 2001 From: Nathan Huey Date: Thu, 25 Jan 2024 14:51:01 -0800 Subject: [PATCH] feat: add check in capability for non hackers --- apps/api/src/admin/participant_manager.py | 12 ++++++++---- apps/api/src/routers/admin.py | 5 ++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/apps/api/src/admin/participant_manager.py b/apps/api/src/admin/participant_manager.py index 354aefe9..2e4e963b 100644 --- a/apps/api/src/admin/participant_manager.py +++ b/apps/api/src/admin/participant_manager.py @@ -47,12 +47,16 @@ async def get_hackers() -> list[Participant]: return [Participant(**user, **user["application_data"]) for user in records] -async def check_in_applicant(uid: str, associate: User) -> None: - """Check in applicant at IrvineHacks""" +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( - Collection.USERS, {"_id": uid, "role": Role.APPLICANT} + Collection.USERS, {"_id": uid, "role": {"$exists": True}} ) - if not record or record["status"] not in (Status.ATTENDING, Status.CONFIRMED): + + if not record or record.get("status", "") not in ( + Status.ATTENDING, + Status.CONFIRMED, + ): raise ValueError new_checkin_entry = (utc_now(), associate.uid) diff --git a/apps/api/src/routers/admin.py b/apps/api/src/routers/admin.py index e8b81be5..a4ff0195 100644 --- a/apps/api/src/routers/admin.py +++ b/apps/api/src/routers/admin.py @@ -253,13 +253,12 @@ async def participants() -> list[Participant]: @router.post("/checkin/{uid}") -async def checkin( +async def check_in_participant( uid: str, associate: Annotated[User, Depends(require_checkin_associate)] ) -> None: """Check in participant at IrvineHacks.""" try: - # TODO: non-hackers - await participant_manager.check_in_applicant(uid, associate) + await participant_manager.check_in_participant(uid, associate) except ValueError: raise HTTPException(status.HTTP_404_NOT_FOUND) except RuntimeError as err: