Merge pull request 'master' (#116) from master into 110_Biotope_codelists

Reviewed-on: SGD-Nord/konova#116
This commit is contained in:
2022-02-16 08:50:40 +01:00
26 changed files with 506 additions and 228 deletions

View File

@@ -65,6 +65,26 @@ class KonovaCode(models.Model):
ret_val += ", " + self.parent.long_name
return ret_val
def add_children(self):
""" Adds all children (resurcively until leaf) as .children to the KonovaCode
Returns:
code (KonovaCode): The manipulated KonovaCode instance
"""
if self.is_leaf:
return None
children = KonovaCode.objects.filter(
code_lists__in=self.code_lists.all(),
parent=self
).order_by(
"long_name"
)
self.children = children
for child in children:
child.add_children()
return self
class KonovaCodeList(models.Model):
"""