paginate issues
This commit is contained in:
parent
421f28f32f
commit
36212394ed
2 changed files with 20 additions and 1 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
{% load humanize %}
|
{% load humanize %}
|
||||||
{% load tracker_tags %}
|
{% load tracker_tags %}
|
||||||
|
{% load bootstrap3 %}
|
||||||
|
|
||||||
{% block title %}{{ issue.name }} - {{ project }} - PonyTracker{% endblock %}
|
{% block title %}{{ issue.name }} - {{ project }} - PonyTracker{% endblock %}
|
||||||
|
|
||||||
|
@ -82,7 +83,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
{% if issues.count %}
|
{% if paginator.count %}
|
||||||
{% for issue in issues %}
|
{% for issue in issues %}
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
{% if issue.closed %}
|
{% if issue.closed %}
|
||||||
|
@ -107,4 +108,10 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
{% if issues %}
|
||||||
|
<div style="text-align: center;">
|
||||||
|
{% bootstrap_pagination issues %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -5,6 +5,7 @@ from django.contrib.auth.decorators import login_required
|
||||||
from django.views.decorators.http import require_http_methods
|
from django.views.decorators.http import require_http_methods
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
|
from django.core.paginator import Paginator, PageNotAnInteger, EmptyPage
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.db.models import Max
|
from django.db.models import Max
|
||||||
|
|
||||||
|
@ -301,6 +302,16 @@ def issue_list(request, project):
|
||||||
issues = issues.annotate(last_activity=Max('events__date')).order_by('last_activity')
|
issues = issues.annotate(last_activity=Max('events__date')).order_by('last_activity')
|
||||||
else: # recently-updated
|
else: # recently-updated
|
||||||
issues = issues.annotate(last_activity=Max('events__date')).order_by('-last_activity')
|
issues = issues.annotate(last_activity=Max('events__date')).order_by('-last_activity')
|
||||||
|
page = request.GET.get('page')
|
||||||
|
paginator = Paginator(issues, settings.ITEMS_PER_PAGE)
|
||||||
|
try:
|
||||||
|
issues = paginator.page(page)
|
||||||
|
except PageNotAnInteger:
|
||||||
|
issues = paginator.page(1)
|
||||||
|
except EmptyPage:
|
||||||
|
issues = paginator.page(paginator.num_pages)
|
||||||
|
else:
|
||||||
|
paginator = None
|
||||||
|
|
||||||
if is_open == '' and is_close == '':
|
if is_open == '' and is_close == '':
|
||||||
is_all = ' active'
|
is_all = ' active'
|
||||||
|
@ -311,6 +322,7 @@ def issue_list(request, project):
|
||||||
c = {
|
c = {
|
||||||
'project': project,
|
'project': project,
|
||||||
'issues': issues,
|
'issues': issues,
|
||||||
|
'paginator': paginator,
|
||||||
'query': query,
|
'query': query,
|
||||||
'sort': sort,
|
'sort': sort,
|
||||||
'is_open': is_open,
|
'is_open': is_open,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue