Skip to content

Commit

Permalink
API check-in system modifications (#342)
Browse files Browse the repository at this point in the history
* API check-in system modifications

- Include hackers with status (`WAITLISTED`, `WAIVER_SIGNED`,
  `CONFIRMED`) in `/admin/participants` endpoint
- Allow check-in leads, along with directors to use the `/admin/checkin`
  endpoint on `CONFIRMED` participants

* fix: typos

* fix validation error, add ACCEPTED to get_hackers
  • Loading branch information
samderanova authored Jan 24, 2024
1 parent e10d102 commit 8256afd
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions apps/api/src/admin/participant_manager.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from logging import getLogger
from typing import Any, Optional
from typing import Any, Optional, Union

from auth.user_identity import User, utc_now
from models.ApplicationData import Decision
from services import mongodb_handler
from services.mongodb_handler import Collection
from utils.user_record import Role, Status, UserRecord
Expand All @@ -14,14 +15,26 @@ class Participant(UserRecord):

first_name: str
last_name: str
status: Status
status: Union[Status, Decision]


async def get_attending_applicants() -> list[Participant]:
"""Fetch all applicants who have a status of ATTENDING"""
async def get_hackers() -> list[Participant]:
"""Fetch all applicants who have a status of ATTENDING, WAIVER_SIGNED, CONFIRMED,
or WAITLISTED."""
records: list[dict[str, Any]] = await mongodb_handler.retrieve(
Collection.USERS,
{"role": Role.APPLICANT, "status": Status.ATTENDING},
{
"role": Role.APPLICANT,
"status": {
"$in": [
Status.ATTENDING,
Status.WAIVER_SIGNED,
Status.CONFIRMED,
Decision.ACCEPTED,
Decision.WAITLISTED,
]
},
},
[
"_id",
"status",
Expand All @@ -39,7 +52,7 @@ async def check_in_applicant(uid: str, associate: User) -> None:
record: Optional[dict[str, object]] = await mongodb_handler.retrieve_one(
Collection.USERS, {"_id": uid, "role": Role.APPLICANT}
)
if not record or record["status"] != Status.ATTENDING:
if not record or record["status"] not in (Status.ATTENDING, Status.CONFIRMED):
raise ValueError

new_checkin_entry = (utc_now(), associate.uid)
Expand Down

0 comments on commit 8256afd

Please sign in to comment.