|
@@ -292,30 +292,29 @@ class User(db.Model, UserMixin, CRUDMixin):
|
|
|
return self
|
|
|
|
|
|
def all_topics(self, page, viewer):
|
|
|
- """Returns a paginated result with all topics the user has created.
|
|
|
+ """Topics made by a given user, most recent first.
|
|
|
|
|
|
:param page: The page which should be displayed.
|
|
|
- :param viewer: The user who is viewing this user. It will return a
|
|
|
- list with topics that the *viewer* has access to and
|
|
|
- thus it will not display all topics from
|
|
|
- the requested user.
|
|
|
+ :param viewer: The user who is viewing the page. Only posts
|
|
|
+ accessible to the viewer will be returned.
|
|
|
+ :rtype: flask_sqlalchemy.Pagination
|
|
|
"""
|
|
|
group_ids = [g.id for g in viewer.groups]
|
|
|
topics = Topic.query.\
|
|
|
filter(Topic.user_id == self.id,
|
|
|
Forum.id == Topic.forum_id,
|
|
|
Forum.groups.any(Group.id.in_(group_ids))).\
|
|
|
+ order_by(Topic.id.desc()).\
|
|
|
paginate(page, flaskbb_config['TOPICS_PER_PAGE'], False)
|
|
|
return topics
|
|
|
|
|
|
def all_posts(self, page, viewer):
|
|
|
- """Returns a paginated result with all posts the user has created.
|
|
|
+ """Posts made by a given user, most recent first.
|
|
|
|
|
|
:param page: The page which should be displayed.
|
|
|
- :param viewer: The user who is viewing this user. It will return a
|
|
|
- list with posts that the *viewer* has access to and
|
|
|
- thus it will not display all posts from
|
|
|
- the requested user.
|
|
|
+ :param viewer: The user who is viewing the page. Only posts
|
|
|
+ accessible to the viewer will be returned.
|
|
|
+ :rtype: flask_sqlalchemy.Pagination
|
|
|
"""
|
|
|
group_ids = [g.id for g in viewer.groups]
|
|
|
posts = Post.query.\
|
|
@@ -323,6 +322,7 @@ class User(db.Model, UserMixin, CRUDMixin):
|
|
|
Post.topic_id == Topic.id,
|
|
|
Topic.forum_id == Forum.id,
|
|
|
Forum.groups.any(Group.id.in_(group_ids))).\
|
|
|
+ order_by(Post.id.desc()).\
|
|
|
paginate(page, flaskbb_config['TOPICS_PER_PAGE'], False)
|
|
|
return posts
|
|
|
|