Coverage for src/schemas/group_schema.py : 100%
Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1from marshmallow import fields
2from marshmallow.validate import Regexp, Length
4from src import ma
5from src.model import GroupModel
6from src.utils import DTOSchema, SQLAlchemyAutoSchema
9class GroupMeta:
10 model = GroupModel
13class GroupBase(SQLAlchemyAutoSchema):
14 class Meta(GroupMeta):
15 pass
18class GroupObject(SQLAlchemyAutoSchema):
19 invitations = ma.Nested("UserBase", many=True)
20 members = ma.Nested("UserBase", many=True)
21 owner = ma.Nested("UserBase")
23 class Meta(GroupMeta):
24 pass
27class GroupCreateSchema(DTOSchema):
28 """ /group [POST]
30 Parameters:
31 - name (Str)
32 """
34 name = fields.Str(
35 required=True,
36 validate=[
37 Length(min=3, max=45),
38 Regexp(
39 r"^([A-Za-z0-9_](?:(?:[A-Za-z0-9_]|(?:\.(?!\.))){0,28}(?:[A-Za-z0-9_]))?)$",
40 error="Invalid name!",
41 ),
42 ],
43 )
46class GroupAddMemberSchema(DTOSchema):
47 """ /group/<string:group_uuid> [PUT]
49 Parameters:
50 - uuid (UUID)
51 """
53 uuid = fields.UUID(required=True)