python3: provide string representations (#40911)
This commit is contained in:
parent
a964e71e45
commit
1aca22f73e
|
@ -28,6 +28,7 @@ from django.db.models.query import QuerySet, Q
|
|||
from django.core.exceptions import ValidationError
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.six import python_2_unicode_compatible
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.timezone import now
|
||||
from django.contrib.postgres.fields import JSONField
|
||||
|
@ -38,6 +39,7 @@ from .search import Unaccent, Lower, JSONTextRef
|
|||
from zoo.zoo_meta.validators import schema_validator
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Transaction(models.Model):
|
||||
created = models.DateTimeField(
|
||||
auto_now_add=True,
|
||||
|
@ -51,7 +53,7 @@ class Transaction(models.Model):
|
|||
blank=True,
|
||||
null=True)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return force_text(self.id)
|
||||
|
||||
@classmethod
|
||||
|
@ -91,6 +93,7 @@ class EntityQuerySet(QuerySet):
|
|||
return qs
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class CommonData(models.Model):
|
||||
def clean(self):
|
||||
if self.schema:
|
||||
|
@ -99,7 +102,7 @@ class CommonData(models.Model):
|
|||
except ValidationError as e:
|
||||
raise ValidationError({'content': e})
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return force_text(self.id)
|
||||
|
||||
class Meta:
|
||||
|
@ -240,6 +243,7 @@ class JobQuerySet(QuerySet):
|
|||
return self.filter(**{'content__$classpath': class_path})
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Job(models.Model):
|
||||
'''Store synchronization messages sent to applications'''
|
||||
SCHEDULER_STEP = 60 * 5 # 5 minutes
|
||||
|
@ -365,7 +369,7 @@ class Job(models.Model):
|
|||
# we do not log on retries, to prevent a storm of errors
|
||||
job.do(log=job.state == cls.STATE_TODO)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return '%s %s' % (self.content['$classpath'], self.id)
|
||||
|
||||
@property
|
||||
|
|
|
@ -22,6 +22,7 @@ from decimal import Decimal
|
|||
import datetime
|
||||
|
||||
from django.core.management.base import BaseCommand, CommandParser
|
||||
from django.utils.six import python_2_unicode_compatible
|
||||
from django.utils.timezone import now
|
||||
|
||||
from zoo.zoo_nanterre.utils import individu_caption
|
||||
|
@ -29,6 +30,7 @@ from zoo.zoo_nanterre.duplicates import find_duplicates
|
|||
from zoo.zoo_nanterre.models import Duplicate
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Table(object):
|
||||
def __init__(self, names):
|
||||
self.size = len(names)
|
||||
|
@ -48,7 +50,7 @@ class Table(object):
|
|||
for i, col in enumerate(row):
|
||||
self.width[i] = max(self.width[i], u'%s' % col)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
self.computesize()
|
||||
s = u'|'
|
||||
for width, name in zip(self.width, self.names):
|
||||
|
|
Loading…
Reference in New Issue