-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschemas.py
More file actions
30 lines (22 loc) · 704 Bytes
/
schemas.py
File metadata and controls
30 lines (22 loc) · 704 Bytes
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
from marshmallow import Schema, fields, validate, post_load
from models import Users, Events
class Credentials(Schema):
username = fields.String()
password = fields.String()
class UserData(Schema):
uid = fields.Integer()
name = fields.String()
@post_load
def make_user(self, data, **kwargs):
return Users(**data)
class EventData(Schema):
uid = fields.Integer()
name = fields.String()
datetime = fields.DateTime()
description = fields.String()
owner = fields.Nested(UserData())
owner_id = fields.Integer()
invited_users = fields.List(fields.Integer)
@post_load
def make_event(self, data, **kwargs):
return Events(**data)