#112 CompensationAction Tree

* implements generic HTML based and Django compatible TreeView
* enhances listing of CompensationActions on DetailView
This commit is contained in:
2022-02-15 10:48:01 +01:00
parent d04d02380f
commit 95856c9ee9
17 changed files with 246 additions and 253 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):
"""