示例#1
0
 def delete(self, classroom_id, student_id):
     try:
         classroom = Classroom.find(id=classroom_id)
         classroom.remove_student(id=student_id)
         return make_response_of_list(classroom.students,
                                      exclude("password"))
     except NotFound:
         return {
             "msg": f"Teacher with id {student_id} is not in this classroom"
         }, 404
     except EnrollmentExists as e:
         return {"msg": str(e)}, 400
示例#2
0
    def put(self, classroom_id):
        args = self.__parser.parse_args()

        try:
            classroom = Classroom.find(id=classroom_id)
            user = classroom.remove_teacher(email=args["email"])
            if user:
                classroom.add_student(user)
            else:
                classroom.add_student(User.find(email=args["email"]))
            return make_response_of_list(
                Classroom.find(id=classroom_id).students, exclude("password"))
        except NotFound:
            return {
                "msg": f"User with email {args['email']} doesn't exist"
            }, 404
        except EnrollmentExists as e:
            return {"msg": str(e)}, 400
示例#3
0
 def get(self):
     return make_response_of_list(
         Classroom.find_all(students=current_user.id), exclude())
示例#4
0
 def get(self, classroom_id):
     return make_response_of_list(
         Classroom.find(id=classroom_id).students, exclude("password"))