aboutsummaryrefslogtreecommitdiff
path: root/src/web/models/user.py
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2016-03-01 22:47:53 +0100
committerCédric Bonhomme <cedric@cedricbonhomme.org>2016-03-01 22:47:53 +0100
commit83081ad7e488c44757e43ff40e83458a2e1451ed (patch)
tree176b04327df88b899aa4172aa30d042a0e43b32a /src/web/models/user.py
parentUseless if no category set. (diff)
downloadnewspipe-83081ad7e488c44757e43ff40e83458a2e1451ed.tar.gz
newspipe-83081ad7e488c44757e43ff40e83458a2e1451ed.tar.bz2
newspipe-83081ad7e488c44757e43ff40e83458a2e1451ed.zip
begin integration of the new architecture
Diffstat (limited to 'src/web/models/user.py')
-rw-r--r--src/web/models/user.py16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/web/models/user.py b/src/web/models/user.py
index 1a276f7e..133901a5 100644
--- a/src/web/models/user.py
+++ b/src/web/models/user.py
@@ -34,9 +34,10 @@ from werkzeug import check_password_hash
from flask.ext.login import UserMixin
from bootstrap import db
+from web.models.right_mixin import RightMixin
-class User(db.Model, UserMixin):
+class User(db.Model, UserMixin, RightMixin):
"""
Represent a user.
"""
@@ -44,14 +45,17 @@ class User(db.Model, UserMixin):
nickname = db.Column(db.String(), unique=True)
email = db.Column(db.String(254), index=True, unique=True)
pwdhash = db.Column(db.String())
- roles = db.relationship('Role', backref='user', lazy='dynamic')
- enabled = db.Column(db.Boolean(), default=False)
date_created = db.Column(db.DateTime(), default=datetime.now)
last_seen = db.Column(db.DateTime(), default=datetime.now)
feeds = db.relationship('Feed', backref='subscriber', lazy='dynamic',
cascade='all,delete-orphan')
refresh_rate = db.Column(db.Integer, default=60) # in minutes
+ # user rights
+ is_active = db.Column(db.Boolean(), default=True)
+ is_admin = db.Column(db.Boolean(), default=False)
+ is_api = db.Column(db.Boolean(), default=False)
+
@staticmethod
def make_valid_nickname(nickname):
return re.sub('[^a-zA-Z0-9_\.]', '', nickname)
@@ -68,12 +72,6 @@ class User(db.Model, UserMixin):
"""
return check_password_hash(self.pwdhash, password)
- def is_admin(self):
- """
- Return True if the user has administrator rights.
- """
- return "admin" in [role.name for role in self.roles]
-
def __eq__(self, other):
return self.id == other.id
bgstack15