-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
27 lines (21 loc) · 889 Bytes
/
models.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
from datetime import date
from mongoengine import Document, EmailField, IntField, StringField, DateTimeField, ReferenceField
class User(Document):
email = EmailField(required=True)
name = StringField(max_length=255, required=True)
surname = StringField(max_length=255, required=True)
class Measurement(Document):
sys = IntField(min_value=0, max_value=200, required=True)
dia = IntField(min_value=0, max_value=200, required=True)
pul = IntField(min_value=0, max_value=200, required=True)
created = DateTimeField(default=date.today, unique=True)
user = ReferenceField(User, required=True)
def to_dic(self):
return {
'id': str(self.id),
'sys': self.sys,
'dia': self.dia,
'pul': self.pul,
'created': self.created.strftime("%Y-%m-%d"),
'user': str(self.user.id)
}