Ejemplo n.º 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
Ejemplo n.º 2
0
 def post(self):
     data = School.parser.parse_args()
     if SchoolModel.find_by_name(data["name"]):
         return {"messages": err_duplicate.format("school")}, 400
     school = SchoolModel(**data)
     try:
         school.save_to_db()
     except:
         return {"messages": err_500}, 500
     return {"messages": noti_201}, 201
Ejemplo n.º 3
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
Ejemplo n.º 4
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