From fca2f063713cb3da74690c70d6ed1a7f9d04c8ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Sat, 11 Jan 2020 18:00:46 +0100 Subject: [PATCH] lingo: add compatibility with jsonfield used on postgresql < 9.4 (#38857) --- combo/apps/lingo/models.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/combo/apps/lingo/models.py b/combo/apps/lingo/models.py index 83b4ded5..204530bf 100644 --- a/combo/apps/lingo/models.py +++ b/combo/apps/lingo/models.py @@ -31,7 +31,7 @@ from django.conf import settings from django.db import models from django.forms import models as model_forms, Select from django.utils.translation import ugettext_lazy as _ -from django.utils import timezone, dateparse +from django.utils import timezone, dateparse, six from django.core.mail import EmailMultiAlternatives from django.core.urlresolvers import reverse from django.core.exceptions import ObjectDoesNotExist, PermissionDenied @@ -99,6 +99,13 @@ class PaymentBackend(models.Model): return self.label def get_payment(self): + if isinstance(self.service_options, six.string_types): + # backward compatibility when used againt postgresql < 9.4 and + # service_options is received as a string. + try: + self.service_options = json.loads(self.service_options) + except ValueError: + pass return eopayment.Payment(self.service, self.service_options)