Skip to content

Commit

Permalink
fixing bug with search/contact pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
sbma44 committed Jun 22, 2010
1 parent e365633 commit 8f503a4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
3 changes: 1 addition & 2 deletions mail/views.py
Expand Up @@ -96,7 +96,7 @@ def index(request, search=[], threads=None):

threads = _annotate_threads(request,threads)

return render_to_response('index.html', {'range': "<strong>%d</strong> - <strong>%d</strong> of <strong>%d</strong>" % (page.start_index(), page.end_index(), threads_count), 'num_pages': p.num_pages , 'next': page_num<p.num_pages and min(p.num_pages,page_num+1) or False, 'prev': page_num>1 and max(1, page_num-1) or False, 'first': '1', 'last': p.num_pages, 'current_page': page_num, 'threads': threads, 'search': " ".join(search), 'search_orig': (_search_string(request) is not None) and _search_string(request) or ''}, context_instance=RequestContext(request))
return render_to_response('index.html', {'range': "<strong>%d</strong> - <strong>%d</strong> of <strong>%d</strong>" % (page.start_index(), page.end_index(), threads_count), 'num_pages': p.num_pages , 'next': page_num<p.num_pages and min(p.num_pages,page_num+1) or False, 'prev': page_num>1 and max(1, page_num-1) or False, 'first': '1', 'last': p.num_pages, 'current_page': page_num, 'threads': threads, 'search': " ".join(search), 'search_orig': (_search_string(request) is not None) and _search_string(request) or '', 'path': request.path}, context_instance=RequestContext(request))

def contact(request, contact_id):
try:
Expand All @@ -110,7 +110,6 @@ def contact(request, contact_id):
threads.append(e.email_thread.id)
threads = Thread.objects.filter(id__in=threads).order_by('-date')


return index(request, threads=threads)

def contacts_index(request):
Expand Down
12 changes: 6 additions & 6 deletions templates/index.html
Expand Up @@ -21,17 +21,17 @@
{% if forloop.last %}
</table>
</div>

<div id="page-navigation">
{% if prev %}
<a href="/?page={{ first }}">&laquo;&nbsp;Newest</a>
<a href="/?page={{ prev }}">&lsaquo;&nbsp;Newer</a>
<a href="{{ path }}?page={{ first }}">&laquo;&nbsp;Newest</a>
<a href="{{ path }}?page={{ prev }}">&lsaquo;&nbsp;Newer</a>
{% endif %}
<span id="page-range">{{ range|safe }}</span>
{% if next %}
<a href="/?page={{ next }}">Older&nbsp;&rsaquo;</a>
<a href="/?page={{ last }}">Oldest&nbsp;&raquo;</a>
{% endif %}

<a href="{{ path }}?page={{ next }}">Older&nbsp;&rsaquo;</a>
<a href="{{ path }}?page={{ last }}">Oldest&nbsp;&raquo;</a>
{% endif %}
</div>
{% endif %}

Expand Down

0 comments on commit 8f503a4

Please sign in to comment.