Hide keyboard shortcuts

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 

3 

4from src import ma 

5from src.model import GroupModel 

6from src.utils import DTOSchema, SQLAlchemyAutoSchema 

7 

8 

9class GroupMeta: 

10 model = GroupModel 

11 

12 

13class GroupBase(SQLAlchemyAutoSchema): 

14 class Meta(GroupMeta): 

15 pass 

16 

17 

18class GroupObject(SQLAlchemyAutoSchema): 

19 invitations = ma.Nested("UserBase", many=True) 

20 members = ma.Nested("UserBase", many=True) 

21 owner = ma.Nested("UserBase") 

22 

23 class Meta(GroupMeta): 

24 pass 

25 

26 

27class GroupCreateSchema(DTOSchema): 

28 """ /group [POST] 

29 

30 Parameters: 

31 - name (Str) 

32 """ 

33 

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 ) 

44 

45 

46class GroupAddMemberSchema(DTOSchema): 

47 """ /group/<string:group_uuid> [PUT] 

48 

49 Parameters: 

50 - uuid (UUID) 

51 """ 

52 

53 uuid = fields.UUID(required=True)