Skip to content

Commit

Permalink
Fix a bug in pagination of search results
Browse files Browse the repository at this point in the history
  • Loading branch information
yml committed Feb 15, 2011
1 parent 383b0b5 commit 7937377
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
5 changes: 4 additions & 1 deletion filer/admin/folderadmin.py
@@ -1,3 +1,5 @@
import urllib

from django.contrib.admin.util import unquote
from django.contrib import admin
from django.core.paginator import Paginator, InvalidPage, EmptyPage
Expand Down Expand Up @@ -168,7 +170,7 @@ def filter_file(qs, terms=[]):
return qs
q = request.GET.get('q', None)
if q:
search_terms = q.split(" ")
search_terms = urllib.unquote_plus(q).split(" ")
else:
search_terms = []
limit_search_to_folder = request.GET.get('limit_search_to_folder', False) in (True, 'on')
Expand Down Expand Up @@ -250,6 +252,7 @@ def filter_file(qs, terms=[]):
'current_url': request.path,
'title': u'Directory listing for %s' % folder.name,
'search_string': ' '.join(search_terms),
'q':urllib.quote_plus(q),
'show_result_count': show_result_count,
'limit_search_to_folder': limit_search_to_folder,
'is_popup': popup_status(request),
Expand Down
1 change: 1 addition & 0 deletions filer/models/virtualitems.py
Expand Up @@ -5,6 +5,7 @@
from django.core import urlresolvers

class DummyFolder(mixins.IconsMixin):
file_type = 'DummyFolder'
name = "Dummy Folder"
is_root = True
is_smart_folder = True
Expand Down
6 changes: 3 additions & 3 deletions filer/templates/admin/filer/folder/directory_table.html
Expand Up @@ -14,7 +14,7 @@
</thead>
<tbody>
{% for item in paginated_items.object_list %}
{% if item.file_type == 'Folder'%}{% with item as subfolder%}
{% if item.file_type == 'Folder' or item.file_type == 'DummyFolder' %}{% with item as subfolder%}
<tr class="{% cycle rowcolors %}">
<td>{% if select_folder %}<a class="insertlink insertlinkButton" href="" onclick="opener.dismissRelatedFolderLookupPopup(window, {{ subfolder.id }}, '{{ subfolder.name }}'); return false;" >&nbsp;</a>{% endif %}</td>
<!-- DirIcon -->
Expand Down Expand Up @@ -63,15 +63,15 @@
</table>
<p class="paginator">
{% if paginated_items.has_previous %}
<a href="?page={{ paginated_items.previous_page_number }}">previous</a>
<a href="?page={{ paginated_items.previous_page_number }}{% if q %}&q={{ q }}{% endif %}">previous</a>
{% endif %}

<span class="this-page">
Page {{ paginated_items.number }} of {{ paginated_items.paginator.num_pages }}.
</span>

{% if paginated_items.has_next %}
<a href="?page={{ paginated_items.next_page_number }}">next</a>
<a href="?page={{ paginated_items.next_page_number }}{% if q %}&q={{ q }}{% endif %}">next</a>
{% endif %}
</p>
</div>

0 comments on commit 7937377

Please sign in to comment.