Further refactor datatables code

This commit is contained in:
Timothy Hobbs
2019-10-11 17:12:39 +02:00
parent 4ca6adbe39
commit 8a57f72349
3 changed files with 107 additions and 97 deletions

View File

@@ -1,4 +1,5 @@
from django.db.models import Q
from django.core.cache import cache
from model_utils import Choices
@@ -87,6 +88,18 @@ def apply_query(queryset, params):
return queryset
def get_query(query, huser):
# Prefilter the allowed tickets
objects = cache.get(huser.user.email + query)
if objects is not None:
return objects
tickets = huser.get_tickets_in_queues().select_related()
query_params = query_from_base64(query)
ticket_qs = apply_query(tickets, query_params)
cache.set(huser.user.email + query, ticket_qs, timeout=60*60)
return ticket_qs
ORDER_COLUMN_CHOICES = Choices(
('0', 'id'),
('2', 'priority'),