-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmodels.py
39 lines (30 loc) · 868 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
28
29
30
31
32
33
34
35
36
37
38
39
__author__ = 'Piotr Dyba'
from flask_login import UserMixin
from sqlalchemy import Column
from sqlalchemy.types import Integer
from sqlalchemy.types import String
from sqlalchemy.types import Boolean
from main import db, lm
@lm.user_loader
def load_user(id):
return User.query.get(int(id))
class User(db.Model, UserMixin):
"""
User model for reviewers.
"""
__tablename__ = 'user'
id = Column(Integer, autoincrement=True, primary_key=True)
active = Column(Boolean, default=True)
email = Column(String(200), unique=True)
password = Column(String(200), default='')
admin = Column(Boolean, default=False)
def is_active(self):
"""
Returns if user is active.
"""
return self.active
def is_admin(self):
"""
Returns if user is admin.
"""
return self.admin