Skip to content

Commit

Permalink
feat: allow students to create on-campus activities
Browse files Browse the repository at this point in the history
  • Loading branch information
7086cmd committed May 21, 2024
1 parent a7a95fc commit 2faa6a1
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions routers/activities_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,15 @@ async def create_activity(payload: Activity, user=Depends(get_current_user)):
status_code=400, detail="Special activity must have a classify"
)

if payload.type == ActivityType.specified and payload.registration is None:
raise HTTPException(
status_code=400, detail="Specified activity must have a registration"
)

if (
none_permission
and payload.type == ActivityType.social
or payload.type == ActivityType.scale
or payload.type == ActivityType.specified
):
payload.status = ActivityStatus.pending
elif (
none_permission
and payload.type == ActivityType.specified
or payload.type == ActivityType.special
):
raise HTTPException(status_code=403, detail="Permission denied")
Expand Down Expand Up @@ -173,17 +168,10 @@ async def change_activity_status(
{"_id": validate_object_id(activity_oid)}
)
# Check user permission
if (
"secretary" not in user["per"]
and "department" not in user["per"]
and "admin" not in user["per"]
and (target_activity["type"] == "social" or target_activity["type"] == "scale")
):
raise HTTPException(status_code=403, detail="Permission denied")
if (
"department" not in user["per"]
and "admin" not in user["per"]
and (target_activity["type"] == "specified")
and (target_activity["type"] == "social" or target_activity["type"] == "scale" or target_activity["type"] == "specified")
):
raise HTTPException(status_code=403, detail="Permission denied")

Expand Down

0 comments on commit 2faa6a1

Please sign in to comment.