29 lines
937 B
Python
29 lines
937 B
Python
from marshmallow import fields, validate
|
|
|
|
from ...dependencies import ma
|
|
from ..validators import validate_index
|
|
from .students import GroupSchema, StudentSchema
|
|
|
|
|
|
class GroupQuerySchema(ma.Schema):
|
|
name = fields.Str()
|
|
page = fields.Integer()
|
|
per_page = fields.Integer()
|
|
|
|
|
|
class GroupsPaginationSchema(ma.Schema):
|
|
groups = fields.List(fields.Nested(GroupSchema))
|
|
max_pages = fields.Integer()
|
|
|
|
|
|
class GroupCreateSchema(ma.Schema):
|
|
name = fields.Str(validate=validate.Length(min=1, max=255), required=True)
|
|
project_supervisor_id = fields.Integer(required=True)
|
|
students = fields.List(fields.Integer(validate=validate_index, required=True))
|
|
|
|
|
|
class GroupEditSchema(ma.Schema):
|
|
name = fields.Str(validate=validate.Length(min=1, max=255))
|
|
project_supervisor_id = fields.Integer(validate=validate_index)
|
|
students = fields.List(fields.Nested(StudentSchema), validate=validate.Length(min=1, max=255))
|