Skip to content

Commit

Permalink
fix(relations): Property names unicode normalization
Browse files Browse the repository at this point in the history
- Set default value for missing name_reverse field
  before attempting unicode normalisation
- Run unicode normalisation on string representations
  of the two name fields
  • Loading branch information
koeaw committed Apr 8, 2024
1 parent ae78620 commit cf14390
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions apis_core/apis_relations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit cf14390

Please sign in to comment.