Skip to content

Commit

Permalink
feat: add check in capability for non hackers (#357)
Browse files Browse the repository at this point in the history
  • Loading branch information
njhuey authored Jan 26, 2024
1 parent 8851229 commit 7ccce0c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
12 changes: 8 additions & 4 deletions apps/api/src/admin/participant_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions apps/api/src/routers/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 7ccce0c

Please sign in to comment.