예제 #1
0
 def post(self, name):
     if SchoolModel.find_by_name(name):
         return {'message': "Trường '{}' Đã tồn tại".format(name)}, 400
     school = SchoolModel(name)
     try:
         school.save_to_db()
     except:
         return {'message': 'Xảy ra lỗi khi tạo 1 trường học'}, 500
     return school.json(), 201
예제 #2
0
    def post(self, name):
        if SchoolModel.find_by_name(name):
            return {'message': "School '{}' already exists".format(name)}, 400

        school = SchoolModel(name)
        try:
            school.save_to_db()
        except:
            return {
                'message': 'An error occurred while creating the school'
            }, 500

        return school.json(), 201
예제 #3
0
 def post(self, schoolName):
     if SchoolModel.find_by_name(schoolName):
         return {
             'message':
             'School with name {} already exists.'.format(schoolName)
         }, 400
     school = SchoolModel(schoolName)
     try:
         school.save_to_db()
     except:
         return {
             'message':
             'An error occurred while saving the school. Database error.'
         }, 500
     return school.json(), 201