Add page count and links to bottom of board view
Current page shows up on the bottom of every board with next/prev links where applicable. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -55,17 +55,24 @@ class BoardView(CreatePostView):
|
||||
template_name = "board/board_detail.html"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
kwargs["board"] = self.board
|
||||
page = self.kwargs.get("page", 1)
|
||||
|
||||
if page not in range(1, self.board.max_pages + 1):
|
||||
raise Http404()
|
||||
|
||||
start = (page - 1) * self.board.threads_per_page
|
||||
end = start + self.board.threads_per_page
|
||||
threads_per_page = self.board.threads_per_page
|
||||
start = (page - 1) * threads_per_page
|
||||
end = start + threads_per_page
|
||||
thread_count = self.board.threads.count()
|
||||
last_page = (thread_count // threads_per_page) + 1
|
||||
|
||||
kwargs["board"] = self.board
|
||||
kwargs["threads"] = self.board.threads.order_by("-last_bump")[start:end]
|
||||
kwargs["page"] = page
|
||||
kwargs["current_page"] = page
|
||||
kwargs["pages"] = range(1, last_page + 1)
|
||||
kwargs["last_page"] = last_page
|
||||
kwargs["max_upload_size"] = settings.MAX_UPLOAD_SIZE
|
||||
|
||||
return super(BoardView, self).get_context_data(**kwargs)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user