Skip to content

Commit

Permalink
ADD chekc to super student add
Browse files Browse the repository at this point in the history
  • Loading branch information
wabscale committed Apr 17, 2024
1 parent a01cfba commit fddb516
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion api/anubis/views/super/students.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,19 @@ def super_students_add(netid: str, name: str):
:return:
"""

user = User.query.filter(User.netid == netid.strip()).first()
if user is not None:
return success_response({
"status": f"Student already exists {netid}",
"user": user.data,
})

user = User(netid=netid.strip(), name=name.strip())
db.session.add(user)
db.session.commit()

return success_response({
"status": f"Added student {netid}"
"status": f"Added student {netid}",
"user": user.data,
})

0 comments on commit fddb516

Please sign in to comment.