Fix saved queries when running in Django 2.0+, for #613

This commit is contained in:
Garret Wassermann 2018-06-27 02:27:24 -04:00
parent 08fc9b5aac
commit 15985e286f

View File

@ -9,6 +9,7 @@ views/staff.py - The bulk of the application - provides most business logic and
from __future__ import unicode_literals
from datetime import datetime, timedelta
import django.VERSION as DJANGO_VERSION
from django.conf import settings
from django.contrib.auth import get_user_model
from django.contrib.auth.decorators import user_passes_test
@ -831,6 +832,10 @@ def ticket_list(request):
from helpdesk.lib import b64decode
try:
if six.PY3:
if DJANGO_VERSION[0] > 1:
# if Django >= 2.0
query_params = json.loads(b64decode(str(saved_query.query).lstrip("b\\'")).decode())
else:
query_params = json.loads(b64decode(str(saved_query.query)).decode())
else:
query_params = json.loads(b64decode(str(saved_query.query)))
@ -1138,6 +1143,10 @@ def run_report(request, report):
from helpdesk.lib import b64decode
try:
if six.PY3:
if DJANGO_VERSION[0] > 1:
# if Django >= 2.0
query_params = json.loads(b64decode(str(saved_query.query).lstrip("b\\'")).decode())
else:
query_params = json.loads(b64decode(str(saved_query.query)).decode())
else:
query_params = json.loads(b64decode(str(saved_query.query)))