# Codelist 288

* introduces 288 to codelist/settings.py
* refactors usage from 975 to 288
* enhances rendering of codelist names depending on which name exists (short vs long)
This commit is contained in:
2024-08-06 15:39:01 +02:00
parent d4d39689cc
commit 94e9035e10
7 changed files with 37 additions and 21 deletions

View File

@@ -50,12 +50,23 @@ class KonovaCode(models.Model):
def __str__(self, with_parent: bool = True):
ret_val = ""
if self.parent and self.parent.long_name and with_parent:
ret_val += self.parent.long_name + " > "
ret_val += self.long_name
if self.short_name and self.short_name != self.long_name:
# Only add short name, if we won't have stupid repition like 'thing a (thing a)' due to misused long-short names
ret_val += f" ({self.short_name})"
long_name = self.long_name
short_name = self.short_name
both_names_exist = long_name and short_name
if both_names_exist:
if with_parent:
if self.parent and self.parent.long_name:
ret_val += self.parent.long_name + " > "
ret_val += long_name
if short_name and short_name != long_name:
ret_val += f" ({short_name})"
else:
ret_val += str(long_name or short_name)
return ret_val
@property