feat: Show all adoption notices of rescue org and children

This commit is contained in:
2025-07-20 16:58:18 +02:00
parent f37d74a7d1
commit bc8feba701
3 changed files with 31 additions and 8 deletions

View File

@@ -193,6 +193,17 @@ class RescueOrganization(models.Model):
def adoption_notices(self):
return AdoptionNotice.objects.filter(organization=self)
@property
def adoption_notices_in_hierarchy(self, adoption_notices=None):
"""
Shows all adoption notices of this rescue organization and all child organizations.
"""
adoption_notices_discovered = list(self.adoption_notices)
if self.child_organizations:
for child in self.child_organizations:
adoption_notices_discovered.extend(child.adoption_notices_in_hierarchy)
return adoption_notices_discovered
@property
def position(self):
if self.location:
@@ -233,6 +244,7 @@ class RescueOrganization(models.Model):
self.exclude_from_check = True
self.save()
@property
def child_organizations(self):
return RescueOrganization.objects.filter(parent_org=self)