Remove "classic" code path and always use datatables for ticket lists

This commit is contained in:
Timothy Hobbs 2019-10-08 17:00:57 +02:00
parent f127b2c224
commit b862732512
5 changed files with 119 additions and 150 deletions

View File

@ -106,9 +106,6 @@ HELPDESK_REDIRECT_TO_LOGIN_BY_DEFAULT = False
LOGIN_URL = '/login/' LOGIN_URL = '/login/'
LOGIN_REDIRECT_URL = '/login/' LOGIN_REDIRECT_URL = '/login/'
# Turn off server-side processing for this local demo
HELPDESK_USE_SERVERSIDE_PROCESSING = False
# Database # Database
# - by default, we use SQLite3 for the demo, but you can also # - by default, we use SQLite3 for the demo, but you can also
# configure MySQL or PostgreSQL, see the docs for more: # configure MySQL or PostgreSQL, see the docs for more:

View File

@ -90,11 +90,6 @@ These changes are visible throughout django-helpdesk
**Default:** ``HELPDESK_ANON_ACCESS_RAISES_404 = False`` **Default:** ``HELPDESK_ANON_ACCESS_RAISES_404 = False``
- **HELPDESK_USE_SERVERSIDE_PROCESSING** If True, may improve performance by utilizing server-side processing of the full ticket list whenever performing queries on the ticket list. Set to False to restore the "classic" functionality using javascript.
**Default:** ``HELPDESK_USE_SERVERSIDE_PROCESSING = True``
Options shown on public pages Options shown on public pages
----------------------------- -----------------------------

View File

@ -151,7 +151,3 @@ HELPDESK_ENABLE_PER_QUEUE_STAFF_PERMISSION = getattr(
# use https in the email links # use https in the email links
HELPDESK_USE_HTTPS_IN_EMAIL_LINK = getattr(settings, 'HELPDESK_USE_HTTPS_IN_EMAIL_LINK', False) HELPDESK_USE_HTTPS_IN_EMAIL_LINK = getattr(settings, 'HELPDESK_USE_HTTPS_IN_EMAIL_LINK', False)
# Asynchronous Datatables - Optional
HELPDESK_USE_SERVERSIDE_PROCESSING = getattr(
settings, 'HELPDESK_USE_SERVERSIDE_PROCESSING', True)

View File

@ -185,9 +185,6 @@
<th>{% trans "Time Spent" %}</th> <th>{% trans "Time Spent" %}</th>
</tr> </tr>
</thead> </thead>
{% if not server_side %}
{% include 'helpdesk/ticket_list_table.html' %}
{% endif %}
</table> </table>
<p><label>{% trans "Select:" %} </label> <p><label>{% trans "Select:" %} </label>
@ -229,15 +226,6 @@
{% block helpdesk_js %} {% block helpdesk_js %}
<script src='{% static "helpdesk/filter.js" %}'></script> <script src='{% static "helpdesk/filter.js" %}'></script>
<script> <script>
{% if not server_side %}
$('#ticketTable').DataTable({
"language": {
"emptyTable": "{% trans 'No Tickets Match Your Selection' %}"
},
"order": [],
responsive: true
});
{% else %}
function get_url(row) function get_url(row)
{ {
return "{% url 'helpdesk:view' 1234 %}".replace(/1234/, row.id.toString()); return "{% url 'helpdesk:view' 1234 %}".replace(/1234/, row.id.toString());
@ -319,7 +307,7 @@
] ]
}); });
}) })
{% endif %}
$(document).ready(function() $(document).ready(function()
{ {
$("#select_all_btn").click(function() { $("#select_all_btn").click(function() {

View File

@ -24,7 +24,6 @@ from django.utils.html import escape
from django import forms from django import forms
from django.utils import timezone from django.utils import timezone
from django.views.generic.edit import FormView, UpdateView from django.views.generic.edit import FormView, UpdateView
# For datatables serverside
from django.core.cache import cache from django.core.cache import cache
from helpdesk.lib import query_tickets_by_args from helpdesk.lib import query_tickets_by_args
@ -972,13 +971,7 @@ 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))
# Serverside processing on datatables is optional. Set
# HELPDESK_USE_SERVERSIDE_PROCESSING to False in settings.py to disable
if helpdesk_settings.HELPDESK_USE_SERVERSIDE_PROCESSING:
cache.set('ticket_qs', ticket_qs) cache.set('ticket_qs', ticket_qs)
context['server_side'] = True
else:
context['server_side'] = False
return render(request, 'helpdesk/ticket_list.html', dict( return render(request, 'helpdesk/ticket_list.html', dict(
context, context,