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

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

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

        student.name = data['name']
        student.school_id = data['school_id']
        student.save()

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

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