From 1e11e227ff762bbe3af1cc5a608d8dffbf8b3932 Mon Sep 17 00:00:00 2001 From: Garret Wassermann Date: Wed, 30 Aug 2017 10:49:56 -0400 Subject: [PATCH] Update ticket_view for Python 2 and 3, to correct a 500 error in #494 --- helpdesk/views/staff.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/helpdesk/views/staff.py b/helpdesk/views/staff.py index ffe2c0aa..c4044d98 100644 --- a/helpdesk/views/staff.py +++ b/helpdesk/views/staff.py @@ -25,6 +25,8 @@ from django.utils.html import escape from django import forms from django.utils import timezone +from django.utils import six + from helpdesk.forms import ( TicketForm, UserSettingsForm, EmailIgnoreForm, EditTicketForm, TicketCCForm, TicketCCEmailForm, TicketCCUserForm, EditFollowUpForm, TicketDependencyForm @@ -817,7 +819,10 @@ def ticket_list(request): import json from helpdesk.lib import b64decode try: - query_params = json.loads(b64decode(str(saved_query.query)).decode()) + if six.PY3: + query_params = json.loads(b64decode(str(saved_query.query)).decode()) + else: + query_params = json.loads(b64decode(str(saved_query.query))) except ValueError: # Query deserialization failed. (E.g. was a pickled query) return HttpResponseRedirect(reverse('helpdesk:list')) @@ -1114,7 +1119,10 @@ def run_report(request, report): import json from helpdesk.lib import b64decode try: - query_params = json.loads(b64decode(str(saved_query.query)).decode()) + if six.PY3: + query_params = json.loads(b64decode(str(saved_query.query)).decode()) + else: + query_params = json.loads(b64decode(str(saved_query.query))) except: return HttpResponseRedirect(reverse('helpdesk:report_index'))