mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-11-22 16:03:19 +01:00
Adds pagination, as per Issue #82.
Thanks to Christian Klein for the patch.
This commit is contained in:
parent
21d38604cf
commit
df30fe9e2a
@ -131,7 +131,7 @@ $(document).ready(function() {
|
|||||||
<table width='100%'>
|
<table width='100%'>
|
||||||
<tr class='row_tablehead'><td colspan='8'>{% trans "Tickets" %}</td></tr>
|
<tr class='row_tablehead'><td colspan='8'>{% trans "Tickets" %}</td></tr>
|
||||||
<tr class='row_columnheads'><th>#</th><th> </th><th>{% trans "Pr" %}</th><th>{% trans "Title" %}</th><th>{% trans "Queue" %}</th><th>{% trans "Status" %}</th><th>{% trans "Created" %}</th><th>{% trans "Owner" %}</th></tr>
|
<tr class='row_columnheads'><th>#</th><th> </th><th>{% trans "Pr" %}</th><th>{% trans "Title" %}</th><th>{% trans "Queue" %}</th><th>{% trans "Status" %}</th><th>{% trans "Created" %}</th><th>{% trans "Owner" %}</th></tr>
|
||||||
{% if tickets %}{% for ticket in tickets %}
|
{% if tickets %}{% for ticket in tickets.object_list %}
|
||||||
<tr class='row_{% cycle odd,even %} row_hover'>
|
<tr class='row_{% cycle odd,even %} row_hover'>
|
||||||
<th><a href='{{ ticket.get_absolute_url }}'>{{ ticket.ticket }}</a></th>
|
<th><a href='{{ ticket.get_absolute_url }}'>{{ ticket.ticket }}</a></th>
|
||||||
<td><input type='checkbox' name='ticket_id' value='{{ ticket.id }}' class='ticket_multi_select' /></td>
|
<td><input type='checkbox' name='ticket_id' value='{{ ticket.id }}' class='ticket_multi_select' /></td>
|
||||||
@ -146,6 +146,21 @@ $(document).ready(function() {
|
|||||||
<tr class='row_odd'><td colspan='5'>{% trans "No Tickets Match Your Selection" %}</td></tr>
|
<tr class='row_odd'><td colspan='5'>{% trans "No Tickets Match Your Selection" %}</td></tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</table>
|
</table>
|
||||||
|
<div class="pagination">
|
||||||
|
<span class="step-links">
|
||||||
|
{% if tickets.has_previous %}
|
||||||
|
<a href="?{{ query_string }}{% if query_string %}&{% else %}?{% endif %}page={{ tickets.previous_page_number }}">{% trans "Previous" %}</a>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<span class="current">
|
||||||
|
{% blocktrans with tickets.number as ticket_num and tickets.paginator.num_pages as num_pages %}Page {{ ticket_num }} of {{ num_pages }}.{% endblocktrans %}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
{% if tickets.has_next %}
|
||||||
|
<a href="?{{ query_string }}{% if query_string %}&{% else %}?{% endif %}page={{ tickets.next_page_number }}">{% trans "Next" %}</a>
|
||||||
|
{% endif %}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
<p><label>Select: </label> <a href='#select_all' id='select_all'>All</a> <a href='#select_none' id='select_none'>None</a> <a href='#select_inverse' id='select_inverse'>Inverse</a></p>
|
<p><label>Select: </label> <a href='#select_all' id='select_all'>All</a> <a href='#select_none' id='select_none'>None</a> <a href='#select_inverse' id='select_inverse'>Inverse</a></p>
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ from django.contrib.auth.models import User
|
|||||||
from django.contrib.auth.decorators import login_required, user_passes_test
|
from django.contrib.auth.decorators import login_required, user_passes_test
|
||||||
from django.core.files.base import ContentFile
|
from django.core.files.base import ContentFile
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
|
from django.core.paginator import Paginator
|
||||||
from django.db import connection
|
from django.db import connection
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from django.http import HttpResponseRedirect, Http404, HttpResponse
|
from django.http import HttpResponseRedirect, Http404, HttpResponse
|
||||||
@ -493,7 +494,17 @@ def ticket_list(request):
|
|||||||
sortreverse = request.GET.get('sortreverse', None)
|
sortreverse = request.GET.get('sortreverse', None)
|
||||||
query_params['sortreverse'] = sortreverse
|
query_params['sortreverse'] = sortreverse
|
||||||
|
|
||||||
tickets = apply_query(Ticket.objects.select_related(), query_params)
|
ticket_qs = apply_query(Ticket.objects.select_related(), query_params)
|
||||||
|
paginator = Paginator(ticket_qs, 20)
|
||||||
|
try:
|
||||||
|
page = int(request.GET.get('page', '1'))
|
||||||
|
except ValueError:
|
||||||
|
page = 1
|
||||||
|
|
||||||
|
try:
|
||||||
|
tickets = paginator.page(page)
|
||||||
|
except (EmptyPage, InvalidPage):
|
||||||
|
tickets = paginator.page(paginator.num_pages)
|
||||||
|
|
||||||
search_message = ''
|
search_message = ''
|
||||||
if context.has_key('query') and settings.DATABASE_ENGINE.startswith('sqlite'):
|
if context.has_key('query') and settings.DATABASE_ENGINE.startswith('sqlite'):
|
||||||
@ -506,9 +517,15 @@ def ticket_list(request):
|
|||||||
|
|
||||||
user_saved_queries = SavedSearch.objects.filter(Q(user=request.user) | Q(shared__exact=True))
|
user_saved_queries = SavedSearch.objects.filter(Q(user=request.user) | Q(shared__exact=True))
|
||||||
|
|
||||||
|
query_string = []
|
||||||
|
for get_key, get_value in request.GET.iteritems():
|
||||||
|
if get_key != "page":
|
||||||
|
query_string.append("%s=%s" % (get_key, get_value))
|
||||||
|
|
||||||
return render_to_response('helpdesk/ticket_list.html',
|
return render_to_response('helpdesk/ticket_list.html',
|
||||||
RequestContext(request, dict(
|
RequestContext(request, dict(
|
||||||
context,
|
context,
|
||||||
|
query_string="&".join(query_string),
|
||||||
tickets=tickets,
|
tickets=tickets,
|
||||||
user_choices=User.objects.filter(is_active=True),
|
user_choices=User.objects.filter(is_active=True),
|
||||||
queue_choices=Queue.objects.all(),
|
queue_choices=Queue.objects.all(),
|
||||||
|
Loading…
Reference in New Issue
Block a user