Fixes for Python 3 and Django 2.0

This commit is contained in:
Garret Wassermann 2018-03-04 01:52:58 -05:00
parent 283f5e9cec
commit 3c456873a5
3 changed files with 16 additions and 4 deletions

View File

@ -14,6 +14,7 @@ from django.core.exceptions import ObjectDoesNotExist
from django.db import models
from django.conf import settings
from django.utils import timezone
from django.utils import six
from django.utils.translation import ugettext_lazy as _, ugettext
from django.utils.encoding import python_2_unicode_compatible
@ -1119,7 +1120,10 @@ class UserSettings(models.Model):
except ImportError:
import cPickle as pickle
from helpdesk.lib import b64encode
self.settings_pickled = b64encode(pickle.dumps(data))
if six.PY2:
self.settings_pickled = b64encode(pickle.dumps(data))
else:
self.settings_pickled = b64encode(pickle.dumps(data)).decode()
def _get_settings(self):
# return a python dictionary representing the pickled data.
@ -1129,7 +1133,10 @@ class UserSettings(models.Model):
import cPickle as pickle
from helpdesk.lib import b64decode
try:
return pickle.loads(b64decode(str(self.settings_pickled)))
if six.PY2:
return pickle.loads(b64decode(str(self.settings_pickled)))
else:
return pickle.loads(b64decode(self.settings_pickled.encode('utf-8')))
except pickle.UnpicklingError:
return {}

View File

@ -7,7 +7,12 @@ views/public.py - All public facing views, eg non-staff (no authentication
required) views.
"""
from django.core.exceptions import ObjectDoesNotExist
from django.core.urlresolvers import reverse
try:
# Django 2.0+
from django.urls import reverse
except ImportError:
# Django < 2
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect, HttpResponse
from django.shortcuts import render
from django.utils.http import urlquote

View File

@ -1,4 +1,4 @@
Django>=1.11,<2
Django>=1.11,<3
django-bootstrap-form>=3.3,<4
email-reply-parser
django-markdown-deux