def ban_student(student_external_id): student = StudentsFinder.get_from_external_id(student_external_id) if student is None: return APIErrorValue('Couldnt find student').json(500) if student.squad: SquadsHandler.delete_squad(student.squad) banned_student = StudentsHandler.create_banned_student(student) if banned_student is None: return APIErrorValue('Error banning student').json(500) UsersHandler.delete_user(student.user) return redirect(url_for('admin_api.students_dashboard'))
def ban_squad(squad_external_id): squad = SquadsFinder.get_from_external_id(squad_external_id) if squad is None: return APIErrorValue('Couldnt find squad').json(500) for member in squad.members: StudentsHandler.leave_squad(member) banned_student = StudentsHandler.create_banned_student(member) if banned_student is None: return APIErrorValue('Error banning student').json(500) UsersHandler.delete_user(member.user) return redirect(url_for('admin_api.squads_dashboard'))