diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2016-10-07 10:59:54 +0200 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2016-10-07 10:59:54 +0200 |
commit | c4eadb099283af409b13146554abf9e5a0cb49a6 (patch) | |
tree | 46cc6357bf50fc9ba884b346e4cd6fd8fcda7ad7 /src/web/models | |
parent | Redirect to the dashboard. (diff) | |
download | newspipe-c4eadb099283af409b13146554abf9e5a0cb49a6.tar.gz newspipe-c4eadb099283af409b13146554abf9e5a0cb49a6.tar.bz2 newspipe-c4eadb099283af409b13146554abf9e5a0cb49a6.zip |
Some other new update for the public profile page.
Diffstat (limited to 'src/web/models')
-rw-r--r-- | src/web/models/user.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/web/models/user.py b/src/web/models/user.py index 2b069728..67181560 100644 --- a/src/web/models/user.py +++ b/src/web/models/user.py @@ -32,6 +32,7 @@ import hashlib from datetime import datetime from werkzeug import check_password_hash from flask_login import UserMixin +from sqlalchemy.orm import validates from bootstrap import db from web.models.right_mixin import RightMixin @@ -51,6 +52,7 @@ class User(db.Model, UserMixin, RightMixin): automatic_crawling = db.Column(db.Boolean(), default=True) is_public_profile = db.Column(db.Boolean(), default=False) + bio = db.Column(db.String(5000), default="") webpage = db.Column(db.String(), default="") twitter = db.Column(db.String(), default="") @@ -82,6 +84,12 @@ class User(db.Model, UserMixin, RightMixin): def make_valid_nickname(nickname): return re.sub('[^a-zA-Z0-9_\.]', '', nickname) + @validates('bio') + def validates_bio(self, key, value): + assert len(value) <= 5000, \ + AssertionError("maximum length for bio: 5000") + return value.strip() + def get_id(self): """ Return the id of the user. |