python3: provide string representations (#40570)
This commit is contained in:
parent
34685564ad
commit
ca7d09f583
|
@ -25,6 +25,7 @@ import psycopg2
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.utils.encoding import force_bytes, force_text
|
from django.utils.encoding import force_bytes, force_text
|
||||||
|
from django.utils.six import python_2_unicode_compatible
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from . import schemas
|
from . import schemas
|
||||||
|
@ -33,6 +34,7 @@ psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
|
||||||
psycopg2.extensions.register_type(psycopg2.extensions.UNICODEARRAY)
|
psycopg2.extensions.register_type(psycopg2.extensions.UNICODEARRAY)
|
||||||
|
|
||||||
|
|
||||||
|
@python_2_unicode_compatible
|
||||||
class DimensionCell(collections.namedtuple('_Cell', ['dimension', 'value', 'value_label'])):
|
class DimensionCell(collections.namedtuple('_Cell', ['dimension', 'value', 'value_label'])):
|
||||||
@property
|
@property
|
||||||
def label(self):
|
def label(self):
|
||||||
|
@ -45,10 +47,11 @@ class DimensionCell(collections.namedtuple('_Cell', ['dimension', 'value', 'valu
|
||||||
else:
|
else:
|
||||||
return force_text(self.value)
|
return force_text(self.value)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return force_text(self.label)
|
return force_text(self.label)
|
||||||
|
|
||||||
|
|
||||||
|
@python_2_unicode_compatible
|
||||||
class MeasureCell(collections.namedtuple('_Cell', ['measure', 'value'])):
|
class MeasureCell(collections.namedtuple('_Cell', ['measure', 'value'])):
|
||||||
@property
|
@property
|
||||||
def label(self):
|
def label(self):
|
||||||
|
@ -87,7 +90,7 @@ class MeasureCell(collections.namedtuple('_Cell', ['measure', 'value'])):
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError('unknown type %s' % self.measure.type)
|
raise NotImplementedError('unknown type %s' % self.measure.type)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return force_text(self.label)
|
return force_text(self.label)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ import datetime
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.http import Http404
|
from django.http import Http404
|
||||||
|
from django.utils.six import python_2_unicode_compatible
|
||||||
from django.utils.text import slugify
|
from django.utils.text import slugify
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from jsonfield import JSONField
|
from jsonfield import JSONField
|
||||||
|
@ -38,6 +39,7 @@ class JSONEncoder(json.JSONEncoder):
|
||||||
return json.JSONEncoder.default(self, obj)
|
return json.JSONEncoder.default(self, obj)
|
||||||
|
|
||||||
|
|
||||||
|
@python_2_unicode_compatible
|
||||||
class Visualization(models.Model):
|
class Visualization(models.Model):
|
||||||
slug = models.SlugField(verbose_name=_('Identifier'), unique=True)
|
slug = models.SlugField(verbose_name=_('Identifier'), unique=True)
|
||||||
name = models.TextField(verbose_name=_('name'))
|
name = models.TextField(verbose_name=_('name'))
|
||||||
|
@ -48,7 +50,7 @@ class Visualization(models.Model):
|
||||||
verbose_name = _('visualization')
|
verbose_name = _('visualization')
|
||||||
verbose_name_plural = _('visualizations')
|
verbose_name_plural = _('visualizations')
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
def natural_key(self):
|
def natural_key(self):
|
||||||
|
|
Loading…
Reference in New Issue