Skip to content

Commit

Permalink
fix(apis_relations): Property save method
Browse files Browse the repository at this point in the history
- Set missing "name_reverse" field before running Unicode checks
- Normalize both name fields (instead of checking + normalizing only
  one)
  • Loading branch information
koeaw committed Mar 5, 2024
1 parent 18ebc9b commit 1cd79af
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions apis_core/apis_relations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 1cd79af

Please sign in to comment.