Skip to content

Commit

Permalink
Hotfix v1.7b - Fixes #2556
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceFox committed Apr 15, 2015
2 parents 72db708 + 1d5428f commit 9f43752
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
3 changes: 1 addition & 2 deletions templates/misc/paginator.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
{% load append_to_get %}
{% load i18n %}


{% if page_obj|length > 1 %}
{% if paginator.num_pages > 1 %}
{% captureas full_anchor %}
{% if anchor %}
#{{ anchor }}
Expand Down
2 changes: 1 addition & 1 deletion templates/mp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
{% endfor %}
</div>

{% include "misc/pagination.part.html" with position='bottom' %}
{% include "misc/paginator.html" with position="bottom" %}
{% endblock %}


Expand Down
2 changes: 1 addition & 1 deletion zds/mp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def get_context_data(self, **kwargs):
context['topic'] = self.object
context['last_post_pk'] = self.object.last_message.pk
context['form'] = PrivatePostForm(self.object)
context['posts'] = self.build_list()
context['posts'] = self.build_list_with_previous_item(context['object_list'])
if never_privateread(self.object):
mark_read(self.object)
return context
Expand Down
5 changes: 3 additions & 2 deletions zds/utils/paginator.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,20 @@ def get_context_data(self, **kwargs):
context.update(kwargs)
return super(MultipleObjectMixin, self).get_context_data(**context)

def build_list(self):
def build_list_with_previous_item(self, queryset):
"""
For some list paginated, we would like to display the last item of the previous page.
This function returns the list paginated with this previous item.
"""
original_list = queryset.all()
list = []
# If necessary, add the last item in the previous page.
if self.page.number != 1:
last_page = self.paginator.page(self.page.number - 1).object_list
last_item = (last_page)[len(last_page) - 1]
list.append(last_item)
# Adds all items of the list paginated.
for item in self.object_list:
for item in original_list:
list.append(item)
return list

Expand Down

0 comments on commit 9f43752

Please sign in to comment.