class EnrollmentSchema(ma.Schema): class Meta: fields = ('id', 'enroll_date', 'student_id', 'course_id', 'student', 'course') student = ma.Nested(UserSchema) course = ma.Nested(CourseSchema)
class CourseExtraSchema(ma.Schema): class Meta: fields = ('id', 'name', 'created_at', 'close_date', 'teacher_id', 'teacher', 'students', 'sections') teacher = ma.Nested(UserProfileSchema) students = ma.Nested(EnrollmentStudentSchema, many=True) sections = ma.Nested(SectionSchema, many=True)
class SectionSchema(ma.Schema): class Meta: fields = ('id', 'count', 'date', 'course_id', 'photo', 'photo_result', 'course', 'attendances', 'links') course = ma.Nested(CourseSchema) attendances = ma.Nested(AttendancesSchema, many=True) links = ma.Hyperlinks({ "class_photo": ma.URLFor("section.photo", name="<photo>"), "class_photo_result": ma.URLFor("section.photo", name="<photo_result>"), })
class AttendancesSchema(ma.Schema): class Meta: fields = ('id', 'student', 'status') student = ma.Nested(UserProfileSchema)
class EnrollmentStudentSchema(ma.Schema): class Meta: fields = ('student', ) student = ma.Nested(UserProfileSchema)
class CourseSchema(ma.Schema): class Meta: fields = ('id', 'name', 'created_at', 'close_date', 'teacher_id', 'teacher') teacher = ma.Nested(UserProfileSchema)