Update ticket_view for Python 2 and 3, to correct a 500 error in #494

This commit is contained in:
Garret Wassermann 2017-08-30 10:49:56 -04:00
parent 04a3c3ff5a
commit 1e11e227ff

View File

@ -25,6 +25,8 @@ from django.utils.html import escape
from django import forms from django import forms
from django.utils import timezone from django.utils import timezone
from django.utils import six
from helpdesk.forms import ( from helpdesk.forms import (
TicketForm, UserSettingsForm, EmailIgnoreForm, EditTicketForm, TicketCCForm, TicketForm, UserSettingsForm, EmailIgnoreForm, EditTicketForm, TicketCCForm,
TicketCCEmailForm, TicketCCUserForm, EditFollowUpForm, TicketDependencyForm TicketCCEmailForm, TicketCCUserForm, EditFollowUpForm, TicketDependencyForm
@ -817,7 +819,10 @@ def ticket_list(request):
import json import json
from helpdesk.lib import b64decode from helpdesk.lib import b64decode
try: 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: except ValueError:
# Query deserialization failed. (E.g. was a pickled query) # Query deserialization failed. (E.g. was a pickled query)
return HttpResponseRedirect(reverse('helpdesk:list')) return HttpResponseRedirect(reverse('helpdesk:list'))
@ -1114,7 +1119,10 @@ def run_report(request, report):
import json import json
from helpdesk.lib import b64decode from helpdesk.lib import b64decode
try: 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: except:
return HttpResponseRedirect(reverse('helpdesk:report_index')) return HttpResponseRedirect(reverse('helpdesk:report_index'))