Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions app/api/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,13 +503,10 @@ def is_confirmed(request: Request, id: str, token: AccessTokenPayload = Depends(
def remove_participant(request: Request, id: str, uid: str, token: AccessTokenPayload = Depends(authorize_admin)):
db = get_database(request)
event = get_event_or_404(db, id)
member = db.members.find_one({'id': UUID(uid)})

if not member:
raise HTTPException(404, "User could not be found")
uid = UUID(uid)

participant = db.events.find_one({"eid": event["eid"]}, {"participants": {
"$elemMatch": {"id": member["id"]}}})
"$elemMatch": {"id": uid}}})

if not participant:
raise HTTPException(400, "User not joined event!")
Expand All @@ -520,7 +517,7 @@ def remove_participant(request: Request, id: str, uid: str, token: AccessTokenPa
raise HTTPException(400, "User not joined event!")

db.events.update_one({'eid': event['eid']}, {
"$pull": {"participants": {"id": member["id"]}}})
"$pull": {"participants": {"id": uid}}})

return Response(status_code=200)

Expand All @@ -541,6 +538,12 @@ async def reorder_participants(request: Request, id: str, position_update: Parti
raise HTTPException(
400, "Not valid: got invalid or outdated participant list")

participants = [
participant
for participant in participants
if db.members.find_one({'id': participant['id']}) != None
]

for participant in position_update.updateList:
participant = participant.model_dump()
for i, p in enumerate(participants):
Expand Down