mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2025-01-19 04:19:54 +01:00
Merge pull request #415 from mhannig/fix-broken-keyword-search
JSON Serialization broke Keyword-Searches
This commit is contained in:
commit
f2e497c3c6
@ -21,6 +21,7 @@ import logging
|
||||
logger = logging.getLogger('helpdesk')
|
||||
|
||||
from django.utils.encoding import smart_str
|
||||
from django.db.models import Q
|
||||
|
||||
def send_templated_mail(template_name, email_context, recipients, sender=None, bcc=None, fail_silently=False, files=None):
|
||||
"""
|
||||
@ -177,17 +178,25 @@ def apply_query(queryset, params):
|
||||
params is a dictionary that contains the following:
|
||||
filtering: A dict of Django ORM filters, eg:
|
||||
{'user__id__in': [1, 3, 103], 'title__contains': 'foo'}
|
||||
other_filter: Another filter of some type, most likely a
|
||||
set of Q() objects.
|
||||
|
||||
search_string: A freetext search string
|
||||
|
||||
sorting: The name of the column to sort by
|
||||
"""
|
||||
for key in params['filtering'].keys():
|
||||
filter = {key: params['filtering'][key]}
|
||||
queryset = queryset.filter(**filter)
|
||||
|
||||
if params.get('other_filter', None):
|
||||
# eg a Q() set
|
||||
queryset = queryset.filter(params['other_filter'])
|
||||
search = params.get('search_string', None)
|
||||
if search:
|
||||
qset = (
|
||||
Q(title__icontains=search) |
|
||||
Q(description__icontains=search) |
|
||||
Q(resolution__icontains=search) |
|
||||
Q(submitter_email__icontains=search)
|
||||
)
|
||||
|
||||
queryset = queryset.filter(qset)
|
||||
|
||||
sorting = params.get('sorting', None)
|
||||
if sorting:
|
||||
|
@ -724,7 +724,7 @@ def ticket_list(request):
|
||||
'sorting': None,
|
||||
'sortreverse': False,
|
||||
'keyword': None,
|
||||
'other_filter': None,
|
||||
'search_string': None,
|
||||
}
|
||||
|
||||
from_saved_query = False
|
||||
@ -834,15 +834,8 @@ def ticket_list(request):
|
||||
q = request.GET.get('q', None)
|
||||
|
||||
if q:
|
||||
qset = (
|
||||
Q(title__icontains=q) |
|
||||
Q(description__icontains=q) |
|
||||
Q(resolution__icontains=q) |
|
||||
Q(submitter_email__icontains=q)
|
||||
)
|
||||
context = dict(context, query=q)
|
||||
|
||||
query_params['other_filter'] = qset
|
||||
query_params['search_string'] = q
|
||||
|
||||
### SORTING
|
||||
sort = request.GET.get('sort', None)
|
||||
|
Loading…
Reference in New Issue
Block a user