-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschemas.py
33 lines (21 loc) · 896 Bytes
/
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
from marshmallow import Schema, fields
class PlainUserSchema(Schema):
id = fields.Integer(dump_only=True)
email = fields.String(required=True)
password = fields.String(required=True, load_only=True)
class PlainCourseSchema(Schema):
id = fields.Integer(dump_only=True)
name = fields.String(required=True)
grade = fields.Float(required=True)
points = fields.Integer(required=True)
user_id = fields.Integer(dump_only=True)
class UpdateCourseSchema(Schema):
name = fields.String(required=True)
grade = fields.Float(required=True)
points = fields.Integer(required=True)
class GpaSchema(Schema):
gpa = fields.Float(dump_only=True)
class UserSchema(PlainUserSchema):
courses = fields.List(fields.Nested(PlainCourseSchema()), dump_only=True)
class CourseSchema(PlainCourseSchema):
user = fields.Nested(PlainUserSchema(), dump_only=True)