Archived
1
0

correct bump order for board page

This commit is contained in:
Jeff Becker 2016-11-06 11:01:04 -05:00
parent 4c7dd44815
commit d81e709827
No known key found for this signature in database
GPG Key ID: AB950234D6EA286B

View File

@ -18,21 +18,8 @@ class BoardView(generic.View):
raise Http404("no such board") raise Http404("no such board")
else: else:
begin = page * group.posts_per_page begin = page * group.posts_per_page
end = begin + group.posts_per_page end = begin + group.posts_per_page - 1
print(begin, end) roots = self.model.objects.filter(newsgroup=group, reference='').order_by('-last_bumped')[begin:end]
posts = self.model.objects.filter(newsgroup=group).order_by('-posted')[begin:end]
roots = []
for post in posts:
if post.is_op():
if post not in roots:
roots.append(post)
else:
op = self.model.objects.filter(msgid=post.reference)
if len(op) > 0:
op = op[0]
if op not in roots:
roots.append(op)
ctx = {'threads': roots,'page': page, 'name': newsgroup} ctx = {'threads': roots,'page': page, 'name': newsgroup}
if page < group.max_pages: if page < group.max_pages:
ctx['nextpage'] = '/{}/{}/'.format(group.name, page + 1) ctx['nextpage'] = '/{}/{}/'.format(group.name, page + 1)