feat: Show all adoption notices of rescue org and children
This commit is contained in:
@@ -193,6 +193,17 @@ class RescueOrganization(models.Model):
|
|||||||
def adoption_notices(self):
|
def adoption_notices(self):
|
||||||
return AdoptionNotice.objects.filter(organization=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
|
@property
|
||||||
def position(self):
|
def position(self):
|
||||||
if self.location:
|
if self.location:
|
||||||
@@ -233,6 +244,7 @@ class RescueOrganization(models.Model):
|
|||||||
self.exclude_from_check = True
|
self.exclude_from_check = True
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
|
@property
|
||||||
def child_organizations(self):
|
def child_organizations(self):
|
||||||
return RescueOrganization.objects.filter(parent_org=self)
|
return RescueOrganization.objects.filter(parent_org=self)
|
||||||
|
|
||||||
|
@@ -76,7 +76,7 @@
|
|||||||
<h2 class="title is-2">{% translate 'Vermittlungen der Organisation' %}</h2>
|
<h2 class="title is-2">{% translate 'Vermittlungen der Organisation' %}</h2>
|
||||||
<div class="container-cards">
|
<div class="container-cards">
|
||||||
{% if org.adoption_notices %}
|
{% if org.adoption_notices %}
|
||||||
{% for adoption_notice in org.adoption_notices %}
|
{% for adoption_notice in org.adoption_notices_in_hierarchy %}
|
||||||
{% include "fellchensammlung/partials/partial-adoption-notice-minimal.html" %}
|
{% include "fellchensammlung/partials/partial-adoption-notice-minimal.html" %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% else %}
|
{% else %}
|
||||||
|
@@ -15,13 +15,24 @@
|
|||||||
|
|
||||||
<div class="cell">
|
<div class="cell">
|
||||||
|
|
||||||
<p>
|
{% if adoption_notice.organization %}
|
||||||
<i class="fa-solid fa-location-dot fa-fw"></i>
|
<div class="cell">
|
||||||
{% if adoption_notice.location %}
|
<span>
|
||||||
{{ adoption_notice.location }}
|
<i class="fa-solid fa-building fa-fw" aria-label="{% trans 'Tierschutzorganisation' %}"></i>
|
||||||
{% else %}
|
<a href="{{ adoption_notice.organization.get_absolute_url }}"> {{ adoption_notice.organization }}</a>
|
||||||
{{ adoption_notice.location_string }}
|
</span>
|
||||||
{% endif %}</p>
|
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<p>
|
||||||
|
<i class="fa-solid fa-location-dot fa-fw"></i>
|
||||||
|
{% if adoption_notice.location %}
|
||||||
|
{{ adoption_notice.location }}
|
||||||
|
{% else %}
|
||||||
|
{{ adoption_notice.location_string }}
|
||||||
|
{% endif %}
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="cell">
|
<div class="cell">
|
||||||
{% include "fellchensammlung/partials/sex-overview.html" %}
|
{% include "fellchensammlung/partials/sex-overview.html" %}
|
||||||
|
Reference in New Issue
Block a user