mirror of
https://github.com/status-im/cabot.git
synced 2025-02-24 02:18:08 +00:00
Added pagination in page statuscheck_detail.html
This commit is contained in:
parent
5dd7ccc0c8
commit
249ea3f665
@ -15,6 +15,7 @@ from django.contrib.auth import get_user_model
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
|
||||
from django.core.urlresolvers import reverse, reverse_lazy
|
||||
from django.core.validators import URLValidator
|
||||
from django.db import transaction
|
||||
@ -564,8 +565,20 @@ class StatusCheckDetailView(LoginRequiredMixin, CommonDetailView):
|
||||
def render_to_response(self, context, *args, **kwargs):
|
||||
if context is None:
|
||||
context = {}
|
||||
context['checkresults'] = self.object.statuscheckresult_set.order_by(
|
||||
'-time_complete')[:100]
|
||||
checkresult_list = self.object.statuscheckresult_set.order_by(
|
||||
'-time_complete').all()
|
||||
paginator = Paginator(checkresult_list, 25)
|
||||
|
||||
page = self.request.GET.get('page')
|
||||
try:
|
||||
checkresults = paginator.page(page)
|
||||
except PageNotAnInteger:
|
||||
checkresults = paginator.page(1)
|
||||
except EmptyPage:
|
||||
checkresults = paginator.page(paginator.num_pages)
|
||||
|
||||
context['checkresults'] = checkresults
|
||||
|
||||
return super(StatusCheckDetailView, self).render_to_response(context, *args, **kwargs)
|
||||
|
||||
|
||||
|
@ -29,7 +29,28 @@
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="col-xs-1"><h3><i class="fa fa-list"></i></h3></div>
|
||||
<div class="col-xs-11"><h3>Check results</h3></div>
|
||||
<div class="col-xs-11">
|
||||
<h3 class="pull-left">Check results</h3>
|
||||
|
||||
{% if checkresults and checkresults.paginator.num_pages > 1 %}
|
||||
<ul class="pagination pagination-sm pull-right">
|
||||
{% if checkresults.has_previous %}
|
||||
<li class="page-item"><a class="page-link" href="?page=1">«</a></li>
|
||||
<li class="page-item"><a class="page-link" href="?page={{ checkresults.previous_page_number }}">{{ checkresults.previous_page_number }}</a></li>
|
||||
{% else %}
|
||||
<li class="page-item disabled"><a class="page-link" href="#">«</a></li>
|
||||
{% endif %}
|
||||
<li class="page-item active"><a class="page-link">{{ checkresults.number }}</a></li>
|
||||
{% if checkresults.has_next %}
|
||||
<li class="page-item"><a class="page-link" href="?page={{ checkresults.next_page_number }}">{{ checkresults.next_page_number }}</a></li>
|
||||
<li class="page-item"><a class="page-link" href="?page={{ checkresults.paginator.num_pages }}">»</a></li>
|
||||
{% else %}
|
||||
<li class="page-item disabled"><a class="page-link" href="#">»</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12">
|
||||
{% if not checkresults %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user