From 04a3c3ff5ac0c7c41317ac29355b4215391d0570 Mon Sep 17 00:00:00 2001 From: Garret Wassermann Date: Wed, 30 Aug 2017 10:48:16 -0400 Subject: [PATCH 1/2] Update decodestring to decodebytes for Py3 since string name was deprecated in py3.1 --- helpdesk/lib.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/helpdesk/lib.py b/helpdesk/lib.py index befbacff..ae8d8944 100644 --- a/helpdesk/lib.py +++ b/helpdesk/lib.py @@ -11,13 +11,17 @@ import mimetypes import os try: + # Python 2 support from base64 import urlsafe_b64encode as b64encode except ImportError: - from base64 import encodestring as b64encode + # Python 3 support + from base64 import encodebytes as b64encode try: + # Python 2 support from base64 import urlsafe_b64decode as b64decode except ImportError: - from base64 import decodestring as b64decode + # Python 3 support + from base64 import decodebytes as b64decode from django.conf import settings from django.db.models import Q From 1e11e227ff762bbe3af1cc5a608d8dffbf8b3932 Mon Sep 17 00:00:00 2001 From: Garret Wassermann Date: Wed, 30 Aug 2017 10:49:56 -0400 Subject: [PATCH 2/2] 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'))