diff --git a/boards/templates/boards/posting_general.html b/boards/templates/boards/posting_general.html
--- a/boards/templates/boards/posting_general.html
+++ b/boards/templates/boards/posting_general.html
@@ -14,23 +14,11 @@
{{ site_name }}
{% endif %}
- {% if current_page.has_previous %}
-
+ {% if prev_page_link %}
+
{% endif %}
- {% if current_page.has_next %}
-
+ {% if next_page_link %}
+
{% endif %}
{% endblock %}
@@ -69,15 +57,9 @@
{% endif %}
{% if threads %}
- {% if current_page.has_previous %}
+ {% if prev_page_link %}
{% endif %}
@@ -107,15 +89,9 @@
{% endfor %}
- {% if current_page.has_next %}
+ {% if next_page_link %}
{% endif %}
{% else %}
diff --git a/boards/views/all_threads.py b/boards/views/all_threads.py
--- a/boards/views/all_threads.py
+++ b/boards/views/all_threads.py
@@ -1,3 +1,4 @@
+from django.core.urlresolvers import reverse
from django.core.files import File
from django.core.files.temp import NamedTemporaryFile
from django.core.paginator import EmptyPage
@@ -28,6 +29,9 @@ PARAMETER_CURRENT_PAGE = 'current_page'
PARAMETER_PAGINATOR = 'paginator'
PARAMETER_THREADS = 'threads'
+PARAMETER_PREV_LINK = 'prev_page_link'
+PARAMETER_NEXT_LINK = 'next_page_link'
+
TEMPLATE = 'boards/posting_general.html'
DEFAULT_PAGE = 1
@@ -57,7 +61,7 @@ class AllThreadsView(PostMixin, BaseBoar
params[PARAMETER_THREADS] = threads
params[CONTEXT_FORM] = form
- self._get_page_context(paginator, params, page)
+ self.get_page_context(paginator, params, page)
return render(request, TEMPLATE, params)
@@ -74,13 +78,29 @@ class AllThreadsView(PostMixin, BaseBoar
return self.get(request, page, form)
- def _get_page_context(self, paginator, params, page):
+ def get_page_context(self, paginator, params, page):
"""
Get pagination context variables
"""
params[PARAMETER_PAGINATOR] = paginator
- params[PARAMETER_CURRENT_PAGE] = paginator.page(int(page))
+ current_page = paginator.page(int(page))
+ params[PARAMETER_CURRENT_PAGE] = current_page
+ if current_page.has_previous():
+ params[PARAMETER_PREV_LINK] = self.get_previous_page_link(
+ current_page)
+ if current_page.has_next():
+ params[PARAMETER_NEXT_LINK] = self.get_next_page_link(current_page)
+
+ def get_previous_page_link(self, current_page):
+ return reverse('index', kwargs={
+ 'page': current_page.previous_page_number(),
+ })
+
+ def get_next_page_link(self, current_page):
+ return reverse('index', kwargs={
+ 'page': current_page.next_page_number(),
+ })
@staticmethod
def parse_tags_string(tag_strings):
diff --git a/boards/views/tag_threads.py b/boards/views/tag_threads.py
--- a/boards/views/tag_threads.py
+++ b/boards/views/tag_threads.py
@@ -1,4 +1,5 @@
from django.shortcuts import get_object_or_404, redirect
+from django.core.urlresolvers import reverse
from boards.abstracts.settingsmanager import get_settings_manager, \
SETTING_FAVORITE_TAGS, SETTING_HIDDEN_TAGS
@@ -48,6 +49,18 @@ class TagView(AllThreadsView, Dispatcher
return params
+ def get_previous_page_link(self, current_page):
+ return reverse('tag', kwargs={
+ 'tag_name': self.tag_name,
+ 'page': current_page.previous_page_number(),
+ })
+
+ def get_next_page_link(self, current_page):
+ return reverse('tag', kwargs={
+ 'tag_name': self.tag_name,
+ 'page': current_page.next_page_number(),
+ })
+
def get(self, request, tag_name, page=DEFAULT_PAGE, form=None):
self.tag_name = tag_name