Ejemplo n.º 1
0
    def delete(self, id):
        school = School.find(id)
        if school is None:
            return {'code': 400, 'message': 'School data not found'}, 400

        School.delete(id)
        return {
            'code': 200,
            'message': 'School data deleted successfully'
        }, 200
Ejemplo n.º 2
0
    def put(self, id):
        _input = SchoolResource.parser.parse_args()

        school = School.find(id)
        if school is None:
            return {'code': 400, 'message': 'School data not found'}, 400

        school.name = _input['name']
        school.save()

        return {
            'code': 200,
            'message': 'School data updated successfully'
        }, 200
Ejemplo n.º 3
0
    def get(self, id):
        school = School.find(id)
        if school is None:
            return {'code': 404, 'message': 'School data not found'}, 404

        return {'code': 200, 'school': school._json()}, 200