convert django lazy string proxies to strings in the base schema validator, rather than in the serialization code of each source model

This commit is contained in:
Gwendolyn 2023-12-11 20:49:50 +01:00
parent 4c06abd400
commit 4b1ac9f194
21 changed files with 126 additions and 104 deletions

View file

@ -88,7 +88,7 @@ class LocationSlug(SerializableMixin, models.Model):
def details_display(self, **kwargs):
result = super().details_display(**kwargs)
result['display'].insert(2, (_('Slug'), str(self.get_slug())))
result['display'].insert(2, (_('Slug'), self.get_slug()))
return result
@cached_property
@ -120,7 +120,7 @@ class Location(LocationSlug, AccessRestrictionMixin, TitledMixin, models.Model):
def _serialize(self, search=False, **kwargs):
result = super()._serialize(**kwargs)
result['subtitle'] = str(self.subtitle)
result['subtitle'] = self.subtitle
result['icon'] = self.get_icon()
result['can_search'] = self.can_search
result['can_describe'] = self.can_search
@ -202,7 +202,7 @@ class SpecificLocation(Location, models.Model):
result['label_settings'] = label_settings.serialize(detailed=False)
if self.label_overrides:
# todo: what if only one language is set?
result['label_override'] = str(self.label_override)
result['label_override'] = self.label_override
return result
def get_label_settings(self):
@ -300,9 +300,9 @@ class LocationGroupCategory(SerializableMixin, models.Model):
result['titles'] = self.titles
result['titles_plural'] = self.titles_plural
result['help_texts'] = self.help_texts
result['title'] = str(self.title)
result['title_plural'] = str(self.title_plural)
result['help_text'] = str(self.help_text)
result['title'] = self.title
result['title_plural'] = self.title_plural
result['help_text'] = self.help_text
result['allow_levels'] = self.allow_levels
result['allow_spaces'] = self.allow_spaces
result['allow_areas'] = self.allow_areas