From 1cd79af765493cae12466b18837afe506cbdaaf3 Mon Sep 17 00:00:00 2001 From: KK Date: Wed, 14 Feb 2024 06:05:07 +0100 Subject: [PATCH] fix(apis_relations): Property save method - Set missing "name_reverse" field before running Unicode checks - Normalize both name fields (instead of checking + normalizing only one) --- apis_core/apis_relations/models.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apis_core/apis_relations/models.py b/apis_core/apis_relations/models.py index 979785f73..99384828b 100644 --- a/apis_core/apis_relations/models.py +++ b/apis_core/apis_relations/models.py @@ -82,11 +82,12 @@ def __str__(self): return self.deprecated_name 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: + if self.name_reverse == "": self.name_reverse = f"{self.deprecated_name} [INVERSE]" + self.deprecated_name = unicodedata.normalize("NFC", self.deprecated_name) + self.name_reverse = unicodedata.normalize("NFC", self.name_reverse) + # TODO RDF: Temporary hack, remove this once better solution is found self.name_forward = self.deprecated_name