|
@ -226,6 +226,11 @@ class User(UserMixin, db.Model): |
|
|
return self.followers.filter_by( |
|
|
return self.followers.filter_by( |
|
|
follower_id=user.id).first() is not None |
|
|
follower_id=user.id).first() is not None |
|
|
|
|
|
|
|
|
|
|
|
@property |
|
|
|
|
|
def followed_posts(self): |
|
|
|
|
|
return Post.query.join(Follow, Follow.followed_id == Post.author_id) \ |
|
|
|
|
|
.filter(Follow.follower_id == self.id) |
|
|
|
|
|
|
|
|
def __repr__(self): |
|
|
def __repr__(self): |
|
|
return '<User %r>' % self.username |
|
|
return '<User %r>' % self.username |
|
|
|
|
|
|
|
|