def delete(self): user = UserModel.get_by_username(get_jwt_identity()) data = request.get_json() if not user.is_admin: return {MESSAGE: "admin privilege required"}, 400 if not ClassroomModel.remove({CLASSROOM_NAME: data[CLASSROOM_NAME]}): return {MESSAGE: "invalid data"}, 400 else: StudentModel.remove({CLASSROOM_NAME: data[CLASSROOM_NAME]}) return {MESSAGE: "classroom deleted"}, 200
def update_students(classroom): StudentModel.remove({CLASSROOM_NAME: classroom.classroom_name}) for username in classroom.user_list: user = UserModel.get_by_username(username) if not user: print("not found user: "******"no student found with username = "******" in classroom " + str(classroom.classroom_name)) continue long_contests = [] for contest in classroom.vjudge_contest_list: long_contests.append({ "contest_title": contest["contest_title"], "contest_id": contest["contest_id"], "total_problems": contest["total_problems"], "minimum_solve_required": contest["minimum_solve_required"], "solved_problems": vjudge_sraper.solve_details_in_contest_from_data( data=data_map[contest[CONTEST_ID]], username=vjudge_handle), "contest_type": contest["contest_type"] }) new_values = {"long_contests": long_contests} student.update_to_mongo(new_values)