Satisfy python2 tests

This commit is contained in:
2020-09-29 19:02:55 +02:00
parent 10ea6affaf
commit 09bfbeedc4
3 changed files with 29 additions and 10 deletions

View File

@@ -15,7 +15,7 @@ from django.db import models
from django.template.loader import get_template
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import get_language, ugettext_lazy as _
from django_countries.fields import CountryField
from django_countries.fields import Country, CountryField
from .. import choices
from .. import config
@@ -326,12 +326,22 @@ class Event(models.Model):
for field in fields:
field_name = field.name
from_value = getattr(event, field_name)
if (isinstance(from_value, datetime.datetime) or
isinstance(from_value, datetime.date) or
isinstance(from_value, datetime.time) or
isinstance(from_value, Country)):
from_value = str(from_value)
to_value = getattr(self, field_name)
if (isinstance(to_value, datetime.datetime) or
isinstance(to_value, datetime.date) or
isinstance(to_value, datetime.time) or
isinstance(to_value, Country)):
to_value = str(to_value)
if from_value != to_value:
change = {
'field': field_name,
'refer': str(from_value),
'current': str(to_value),
'refer': from_value,
'current': to_value,
}
changes.append(change)
diff_text = json.dumps(changes)