diff --git a/app/models.py b/app/models.py index 73de129..bb17087 100644 --- a/app/models.py +++ b/app/models.py @@ -50,12 +50,15 @@ class User(db.Model): version += 1 return new_nickname + @property def is_authenticated(self): return True + @property def is_active(self): return True + @property def is_anonymous(self): return False diff --git a/app/templates/base.html b/app/templates/base.html index 94cbb7a..5ffccf5 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -47,13 +47,13 @@ microblog
diff --git a/app/translate.py b/app/translate.py old mode 100755 new mode 100644 diff --git a/app/views.py b/app/views.py index 23125ca..9bfe169 100644 --- a/app/views.py +++ b/app/views.py @@ -28,7 +28,7 @@ def get_locale(): @app.before_request def before_request(): g.user = current_user - if g.user.is_authenticated(): + if g.user.is_authenticated: g.user.last_seen = datetime.utcnow() db.session.add(g.user) db.session.commit() @@ -84,7 +84,7 @@ def index(page=1): @app.route('/login', methods=['GET', 'POST']) @oid.loginhandler def login(): - if g.user is not None and g.user.is_authenticated(): + if g.user is not None and g.user.is_authenticated: return redirect(url_for('index')) form = LoginForm() if form.validate_on_submit(): diff --git a/requirements.txt b/requirements.txt index 366f76c..3392186 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ Babel==1.3 Flask==0.10.1 Flask-Babel==0.9 -Flask-Login==0.2.11 +Flask-Login==0.3.0 Flask-Mail==0.9.0 Flask-OpenID==1.2.1 Flask-SQLAlchemy==2.0 diff --git a/tests.py b/tests.py index 880389e..08ac5a5 100755 --- a/tests.py +++ b/tests.py @@ -37,9 +37,9 @@ class TestCase(unittest.TestCase): u = User(nickname='john', email='john@example.com') db.session.add(u) db.session.commit() - assert u.is_authenticated() is True - assert u.is_active() is True - assert u.is_anonymous() is False + assert u.is_authenticated is True + assert u.is_active is True + assert u.is_anonymous is False assert u.id == int(u.get_id()) def test_avatar(self):