Commits

Blue committed cf8f49f Merge

Merged

  • Participants
  • Parent commits 9d47335, b2497ea

Comments (0)

Files changed (3)

   - pip install https://github.com/dcramer/pyflakes/tarball/master
   - pip install -q -e . --use-mirrors
 before_script:
-  - "pep8 --exclude=migrations --ignore=E501,E272,E221,E241 spotnet"
-  -  '[ "$TRAVIS_PYTHON_VERSION" \> 3 ] || pyflakes -x W spotnet'
+  - 'pep8 --exclude=migrations --ignore=E501,E272,E221,E241 spotnet'
+  - '[ "$TRAVIS_PYTHON_VERSION" \> 3 ] || pyflakes -x W spotnet'
 script:
   - python example_project/manage.py test

File spotnet/templates/spotnet/paginate.html

 
 <div class="pagination">
   <ul>
-{% if page.has_previous %}
+{% if page.number > 1 %}
+    <li class="walk"><a href="?page=1">{% trans "First" %}</a></li>
+{% endif %}
+{% if page.number > 2 %}
     <li class="walk"><a href="?page={{ page.previous_page_number }}">{% trans "Previous" %}</a></li>
 {% else %}
     <li class="disable"><span>{% trans "Previous" %}</span></li>
 {% else %}
     <li class="disable"><span>{% trans "Next" %}</span></li>
 {% endif %}
+    <li class="walk"><a href="?page=last">{% trans "Last" %}</a></li>
   </ul>
 </div>
-
-{% comment %}
-{% for n in page.paginator.slim_page_range %}
-{% if n = page.number %}
-    <li class="current"><a href="?page={{ n }}">{{ n }}</a></li>
-{% else %}
-    <li><a href="?page={{ n }}">{{ n }}</a></li>
-{% endif %}
-{% endfor %}
-{% endcomment %}

File spotnet/views.py

 
 @authenticate
 def search(request, search=None, cats=None, scats=None):
-    page = request.GET.get('page', 1)
+    page_number = request.GET.get('page', 1)
     searcher = Searcher(search, cats, scats)
     snps = Post.objects.order_by('-posted')
     snps = searcher.filter_queryset(snps)
         allow_empty_first_page=True,
         orphans=0,
     )
-    try:
-        page = paginator.page(page)
-    except InvalidPage, EmptyPage:
-        raise Http404
+
+    if page_number == "last":
+        page = paginator.page(paginator.num_pages)
+    else:
+        try:
+            page = paginator.page(page_number)
+        except InvalidPage, EmptyPage:
+            raise Http404
     return render(
         request,
         'spotnet/list.html',