From cb4e73a891a722d3fa82504d98c7d1292e473326 Mon Sep 17 00:00:00 2001 From: KK Date: Mon, 8 Apr 2024 12:40:19 +0200 Subject: [PATCH] fix(relations): Property fields unicode normalization - Set default value for missing name_reverse field before attempting unicode normalisation - Run unicode normalisation on string representations of the two name fields --- apis_core/apis_relations/models.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/apis_core/apis_relations/models.py b/apis_core/apis_relations/models.py index 6bbc93621..fa1aa1a98 100644 --- a/apis_core/apis_relations/models.py +++ b/apis_core/apis_relations/models.py @@ -81,10 +81,12 @@ def __str__(self): return self.name_forward def save(self, *args, **kwargs): - if self.name_reverse != unicodedata.normalize("NFC", self.name_reverse): - self.name_reverse = unicodedata.normalize("NFC", self.name_reverse) - if self.name_reverse == "" or self.name_reverse is None: - self.name_reverse = self.name_forward + " [REVERSE]" + if self.name_reverse == "": + self.name_reverse = f"{self.name_forward} [INVERSE]" + + self.name_forward = unicodedata.normalize("NFC", str(self.name_forward)) + self.name_reverse = unicodedata.normalize("NFC", str(self.name_reverse)) + super(Property, self).save(*args, **kwargs) return self