From c4eadb099283af409b13146554abf9e5a0cb49a6 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Fri, 7 Oct 2016 10:59:54 +0200 Subject: Some other new update for the public profile page. --- src/web/models/user.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/web/models') 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. -- cgit