from marshmallow import Schema, fields, validate class TermOfDefenceSchema(Schema): start_date = fields.DateTime(required=True) end_date = fields.DateTime(required=True) project_supervisors = fields.List( fields.Integer(required=True), validate=validate.Length(3, 3) ) chairman_of_committee = fields.Integer(required=True) class ProjectSupervisorForTermOfDefenceSchema(Schema): id = fields.Str() first_name = fields.Str() last_name = fields.Str() class TermOfDefenceItemSchema(Schema): id = fields.Integer() start_date = fields.DateTime() end_date = fields.DateTime() members_of_committee = fields.List( fields.Nested(ProjectSupervisorForTermOfDefenceSchema) ) chairman_of_committee = fields.Integer() class TermOfDefenceListSchema(Schema): term_of_defences = fields.List(fields.Nested(TermOfDefenceItemSchema)) class StudentDataItemAssignedGroupSchema(Schema): index = fields.Integer() first_name = fields.Str() last_name = fields.Str() class GroupDataItemAssignedGroupSchema(Schema): name = fields.Str() students = fields.List(fields.Nested(StudentDataItemAssignedGroupSchema)) class AssignedGroupToTermOfDefenceDataItemSchema(TermOfDefenceItemSchema): group = fields.Nested(GroupDataItemAssignedGroupSchema) class AssignedGroupToTermOfDefenceListSchema(Schema): term_of_defences = fields.List( fields.Nested(AssignedGroupToTermOfDefenceDataItemSchema) ) class ProjectSupervisorForTemporaryAvailabilitySchema(Schema): id = fields.Str() first_name = fields.Str() last_name = fields.Str() class TemporaryAvailabilityItemSchema(Schema): start_date = fields.DateTime() end_date = fields.DateTime() project_supervisor = fields.Nested(ProjectSupervisorForTemporaryAvailabilitySchema) class TemporaryAvailabilityListSchema(Schema): temporary_availabilities = fields.List( fields.Nested(TemporaryAvailabilityItemSchema) )