don't cast ugettext_lazy calls to str, as our json encoder is now clever

This commit is contained in:
Laura Klünder 2017-11-30 01:10:49 +01:00
parent 2d292844d6
commit a7c140a2ac
7 changed files with 26 additions and 28 deletions

View file

@ -97,7 +97,7 @@ class AccessRestrictionMixin(SerializableMixin, models.Model):
def details_display(self):
result = super().details_display()
result['display'].extend([
(str(_('Access Restriction')), self.access_restriction_id and self.access_restriction.title),
(_('Access Restriction'), self.access_restriction_id and self.access_restriction.title),
])
return result

View file

@ -36,8 +36,8 @@ class SerializableMixin(models.Model):
return {
'id': self.pk,
'display': [
(str(_('Type')), str(self.__class__._meta.verbose_name)),
(str(_('ID')), str(self.pk)),
(_('Type'), str(self.__class__._meta.verbose_name)),
(_('ID'), str(self.pk)),
]
}

View file

@ -52,7 +52,7 @@ class LevelGeometryMixin(GeometryMixin):
def details_display(self):
result = super().details_display()
result['display'].insert(3, (
str(_('Level')),
_('Level'),
{
'id': self.level_id,
'slug': self.level.get_slug(),
@ -120,8 +120,8 @@ class Space(LevelGeometryMixin, SpecificLocation, models.Model):
def details_display(self):
result = super().details_display()
result['display'].extend([
(str(_('height')), self.height),
(str(_('outside only')), str(_('Yes') if self.outside else _('No'))),
(_('height'), self.height),
(_('outside only'), _('Yes') if self.outside else _('No')),
])
result['editor_url'] = reverse('editor.spaces.detail', kwargs={'level': self.level_id, 'pk': self.pk})
return result

View file

@ -60,7 +60,7 @@ class SpaceGeometryMixin(GeometryMixin):
def details_display(self):
result = super().details_display()
result['display'].insert(3, (
str(_('Space')),
_('Space'),
{
'id': self.space_id,
'slug': self.space.get_slug(),

View file

@ -79,10 +79,10 @@ class Level(SpecificLocation, models.Model):
def details_display(self):
result = super().details_display()
result['display'].insert(3, (str(_('short label')), self.short_label))
result['display'].insert(3, (_('short label'), self.short_label))
result['display'].extend([
(str(_('outside only')), self.base_altitude),
(str(_('default height')), self.default_height),
(_('outside only'), self.base_altitude),
(_('default height'), self.default_height),
])
result['editor_url'] = reverse('editor.levels.detail', kwargs={'pk': self.pk})
return result

View file

@ -61,7 +61,7 @@ class LocationSlug(SerializableMixin, models.Model):
def details_display(self):
result = super().details_display()
result['display'].insert(2, (str(_('Slug')), str(self.get_slug())))
result['display'].insert(2, (_('Slug'), str(self.get_slug())))
return result
@cached_property
@ -105,8 +105,8 @@ class Location(LocationSlug, AccessRestrictionMixin, TitledMixin, models.Model):
def details_display(self):
result = super().details_display()
result['display'].extend([
(str(_('searchable')), str(_('Yes') if self.can_search else _('No'))),
(str(_('can describe')), str(_('Yes') if self.can_describe else _('No')))
(_('searchable'), _('Yes') if self.can_search else _('No')),
(_('can describe'), _('Yes') if self.can_describe else _('No'))
])
return result
@ -262,10 +262,10 @@ class LocationGroup(Location, models.Model):
def details_display(self):
result = super().details_display()
result['display'].insert(3, (str(_('Category')), self.category.title))
result['display'].insert(3, (_('Category'), self.category.title))
result['display'].extend([
(str(_('color')), self.color),
(str(_('priority')), self.priority),
(_('color'), self.color),
(_('priority'), self.priority),
])
result['editor_url'] = reverse('editor.locationgroups.edit', kwargs={'pk': self.pk})
return result

View file

@ -237,10 +237,8 @@ class CustomLocation:
self.level = level
self.x = x
self.y = y
self.title = str(_('Coordinates'))
self.subtitle = str(_('%(level)s, x=%(x)s, y=%(y)s') % {'level': self.level.title,
'x': self.x,
'y': self.y})
self.title = _('Coordinates')
self.subtitle = _('%(level)s, x=%(x)s, y=%(y)s') % {'level': self.level.title, 'x': self.x, 'y': self.y}
@property
def serialized_geometry(self):
@ -268,19 +266,19 @@ class CustomLocation:
return {
'id': self.pk,
'display': [
(str(_('Type')), str(_('Coordinates'))),
(str(_('ID')), str(self.pk)),
(str(_('Slug')), str(self.pk)),
(str(_('Level')), {
(_('Type'), _('Coordinates')),
(_('ID'), self.pk),
(_('Slug'), self.pk),
(_('Level'), {
'id': self.level.pk,
'slug': self.level.get_slug(),
'title': self.level.title,
'can_search': self.level.can_search,
}),
(str(_('X Coordinate')), str(self.x)),
(str(_('Y Coordinate')), str(self.y)),
(str(_('Title')), str(self.title)),
(str(_('Subtitle')), str(self.subtitle)),
(_('X Coordinate'), str(self.x)),
(_('Y Coordinate'), str(self.y)),
(_('Title'), self.title),
(_('Subtitle'), self.subtitle),
],
'geometry': self.serialized_geometry,
}