mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2025-01-31 18:39:16 +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')
|
logger = logging.getLogger('helpdesk')
|
||||||
|
|
||||||
from django.utils.encoding import smart_str
|
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):
|
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:
|
params is a dictionary that contains the following:
|
||||||
filtering: A dict of Django ORM filters, eg:
|
filtering: A dict of Django ORM filters, eg:
|
||||||
{'user__id__in': [1, 3, 103], 'title__contains': 'foo'}
|
{'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
|
sorting: The name of the column to sort by
|
||||||
"""
|
"""
|
||||||
for key in params['filtering'].keys():
|
for key in params['filtering'].keys():
|
||||||
filter = {key: params['filtering'][key]}
|
filter = {key: params['filtering'][key]}
|
||||||
queryset = queryset.filter(**filter)
|
queryset = queryset.filter(**filter)
|
||||||
|
|
||||||
if params.get('other_filter', None):
|
search = params.get('search_string', None)
|
||||||
# eg a Q() set
|
if search:
|
||||||
queryset = queryset.filter(params['other_filter'])
|
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)
|
sorting = params.get('sorting', None)
|
||||||
if sorting:
|
if sorting:
|
||||||
|
@ -724,7 +724,7 @@ def ticket_list(request):
|
|||||||
'sorting': None,
|
'sorting': None,
|
||||||
'sortreverse': False,
|
'sortreverse': False,
|
||||||
'keyword': None,
|
'keyword': None,
|
||||||
'other_filter': None,
|
'search_string': None,
|
||||||
}
|
}
|
||||||
|
|
||||||
from_saved_query = False
|
from_saved_query = False
|
||||||
@ -834,15 +834,8 @@ def ticket_list(request):
|
|||||||
q = request.GET.get('q', None)
|
q = request.GET.get('q', None)
|
||||||
|
|
||||||
if q:
|
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)
|
context = dict(context, query=q)
|
||||||
|
query_params['search_string'] = q
|
||||||
query_params['other_filter'] = qset
|
|
||||||
|
|
||||||
### SORTING
|
### SORTING
|
||||||
sort = request.GET.get('sort', None)
|
sort = request.GET.get('sort', None)
|
||||||
|
Loading…
Reference in New Issue
Block a user