Merge branch 'master' into 132_Old_entries

# Conflicts:
#	konova/management/commands/update_all_parcels.py
#	konova/urls.py
#	user/admin.py
This commit is contained in:
2022-06-01 13:12:35 +02:00
160 changed files with 62451 additions and 794 deletions
+4 -5
View File
@@ -65,24 +65,23 @@ class KonovaCode(models.Model):
ret_val += ", " + self.parent.long_name
return ret_val
def add_children(self):
def add_children(self, order_by: str = "long_name"):
""" Adds all children (resurcively until leaf) as .children to the KonovaCode
Returns:
code (KonovaCode): The manipulated KonovaCode instance
"""
if self.is_leaf:
return None
return self
children = KonovaCode.objects.filter(
code_lists__in=self.code_lists.all(),
parent=self
).order_by(
"long_name"
order_by
)
self.children = children
for child in children:
child.add_children()
child.add_children(order_by)
return self