-
Notifications
You must be signed in to change notification settings - Fork 0
/
schemas.py
62 lines (48 loc) · 1.99 KB
/
schemas.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from marshmallow import Schema, fields
class PlainTagSchema(Schema):
id = fields.Int(dump_only=True)
name = fields.Str()
class PlainTaskSchema(Schema):
id = fields.Str(dump_only=True)
title = fields.Str(required=True)
description = fields.Str(required=True)
class PlainProjectSchema(Schema):
id = fields.Str(dump_only=True)
name = fields.Str(required=True)
description = fields.Str(required=True)
class PlainCourseSchema(Schema):
id = fields.Str(dump_only=True)
name = fields.Str(required=True)
class ProjectSchema(PlainProjectSchema):
course_id = fields.Int(required=True, load_only=True)
course = fields.Nested(PlainCourseSchema(), dump_only=True)
tasks = fields.List(fields.Nested(PlainTaskSchema()), dump_only=True)
tags = fields.List(fields.Nested(PlainTagSchema()), dump_only=True)
class TaskSchema(PlainTaskSchema):
project_id = fields.Int(required=True, load_only=True)
project = fields.Nested(PlainProjectSchema(), dump_only=True)
class ProjectUpdateSchema(Schema):
name = fields.Str()
description = fields.Str()
course_id = fields.Int()
class TaskUpdateSchema(Schema):
title = fields.Str()
description = fields.Str()
project_id = fields.Int()
class CourseSchema(PlainCourseSchema):
projects = fields.List(fields.Nested(PlainProjectSchema()), dump_only=True)
tags = fields.List(fields.Nested(PlainTagSchema()), dump_only=True)
class UserSchema(Schema):
id = fields.Int(dump_only=True)
username = fields.Str(required=True)
password = fields.Str(required=True, load_only=True)
class TagSchema(PlainTagSchema):
course_id = fields.Int(load_only=True)
projects = fields.List(fields.Nested(PlainProjectSchema()), dump_only=True)
course = fields.Nested(PlainCourseSchema(), dump_only=True)
class TagAndProjectSchema(Schema):
message = fields.Str()
project = fields.Nested(ProjectSchema)
tag = fields.Nested(TagSchema)
class UserRegisterSchema(UserSchema):
email = fields.Str(required=True)