mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-11-22 16:03:19 +01:00
Merge pull request #544 from gwasser/decode
Support b64 decoding on py2 and py3
This commit is contained in:
commit
87ee738428
@ -11,13 +11,17 @@ import mimetypes
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
# Python 2 support
|
||||||
from base64 import urlsafe_b64encode as b64encode
|
from base64 import urlsafe_b64encode as b64encode
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from base64 import encodestring as b64encode
|
# Python 3 support
|
||||||
|
from base64 import encodebytes as b64encode
|
||||||
try:
|
try:
|
||||||
|
# Python 2 support
|
||||||
from base64 import urlsafe_b64decode as b64decode
|
from base64 import urlsafe_b64decode as b64decode
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from base64 import decodestring as b64decode
|
# Python 3 support
|
||||||
|
from base64 import decodebytes as b64decode
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
|
@ -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'))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user