From 182d55335630abea08e29fb822acd1f7facc902f Mon Sep 17 00:00:00 2001 From: Garret Wassermann Date: Sat, 12 Oct 2019 18:58:50 -0400 Subject: [PATCH] Fix some renaming issues from most recent merge --- helpdesk/migrations/0002_populate_usersettings.py | 6 +++--- helpdesk/tests/test_attachments.py | 6 +++--- helpdesk/views/staff.py | 14 +++++++++++++- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/helpdesk/migrations/0002_populate_usersettings.py b/helpdesk/migrations/0002_populate_usersettings.py index 9c60205f..b35bfc80 100644 --- a/helpdesk/migrations/0002_populate_usersettings.py +++ b/helpdesk/migrations/0002_populate_usersettings.py @@ -5,13 +5,13 @@ from django.db import models, migrations from helpdesk.settings import DEFAULT_USER_SETTINGS -def picke_settings(data): +def pickle_settings(data): """Pickling as defined at migration's creation time""" try: import pickle except ImportError: import cPickle as pickle - from helpdesk.lib import b64encode + from helpdesk.query import b64encode return b64encode(pickle.dumps(data)) @@ -27,7 +27,7 @@ def populate_usersettings(apps, schema_editor): # Import historical version of models UserSettings = apps.get_model("helpdesk", "UserSettings") - settings_pickled = picke_settings(DEFAULT_USER_SETTINGS) + settings_pickled = pickle_settings(DEFAULT_USER_SETTINGS) for u in User.objects.all(): try: diff --git a/helpdesk/tests/test_attachments.py b/helpdesk/tests/test_attachments.py index 2f011d71..89b50017 100644 --- a/helpdesk/tests/test_attachments.py +++ b/helpdesk/tests/test_attachments.py @@ -98,7 +98,7 @@ class AttachmentUnitTests(TestCase): @mock.patch('helpdesk.lib.FollowUpAttachment', autospec=True) def test_unicode_attachment_filename(self, mock_att_save, mock_queue_save, mock_ticket_save, mock_follow_up_save): - """ check utf-8 data is parsed correcltly """ + """ check utf-8 data is parsed correctly """ filename, fileobj = lib.process_attachments(self.follow_up, [self.test_file])[0] mock_att_save.assert_called_with( file=self.test_file, @@ -111,7 +111,7 @@ class AttachmentUnitTests(TestCase): @mock.patch('helpdesk.lib.FollowUpAttachment', autospec=True) def test_autofill(self, mock_att_save, mock_queue_save, mock_ticket_save, mock_follow_up_save): - """ check utf-8 data is parsed correcltly """ + """ check utf-8 data is parsed correctly """ self.follow_up.pk = 100 obj = models.FollowUpAttachment.objects.create( followup=self.follow_up, @@ -122,7 +122,7 @@ class AttachmentUnitTests(TestCase): self.assertEqual(obj.mime_type, "text/plain") def test_kbi_attachment(self, mock_att_save, mock_queue_save, mock_ticket_save): - """ check utf-8 data is parsed correcltly """ + """ check utf-8 data is parsed correctly """ kbcategory = models.KBCategory.objects.create( title="Title", diff --git a/helpdesk/views/staff.py b/helpdesk/views/staff.py index 240d97a4..14b6be86 100644 --- a/helpdesk/views/staff.py +++ b/helpdesk/views/staff.py @@ -906,9 +906,20 @@ def ticket_list(request): urlsafe_query = query_to_base64(query_params) - get_query(urlsafe_query, huser) + tickets_base = get_query(urlsafe_query, huser) user_saved_queries = SavedSearch.objects.filter(Q(user=request.user) | Q(shared__exact=True)) + + ticket_qs = None + try: + ticket_qs = apply_query(tickets_base, query_params) + except ValidationError: + # invalid parameters in query, return default query + query_params = { + 'filtering': {'status__in': [1, 2, 3]}, + 'sorting': 'created', + } + ticket_qs = apply_query(tickets_base, query_params) search_message = '' if query_params['search_string'] and settings.DATABASES['default']['ENGINE'].endswith('sqlite'): @@ -923,6 +934,7 @@ def ticket_list(request): return render(request, 'helpdesk/ticket_list.html', dict( context, + tickets=ticket_qs, default_tickets_per_page=request.user.usersettings_helpdesk.tickets_per_page, user_choices=User.objects.filter(is_active=True, is_staff=True), queue_choices=huser.get_queues(),