feat: Add basic embeddable view for ans of rescue orgs

This commit is contained in:
2025-09-10 17:44:33 +02:00
parent df15ea100b
commit 5a2b11b44e
9 changed files with 120 additions and 4 deletions

View File

@@ -0,0 +1,18 @@
from django.shortcuts import get_object_or_404, render
from fellchensammlung.aviews.helpers import headers
from fellchensammlung.models import RescueOrganization, AdoptionNotice, Species
@headers({"X-Robots-Tag": "noindex"})
def list_ans_per_rescue_organization(request, rescue_organization_id, species_slug=None):
org = get_object_or_404(RescueOrganization, pk=rescue_organization_id)
if species_slug is None:
adoption_notices = AdoptionNotice.objects.filter(organization=org)
else:
ans_of_rescue_org = AdoptionNotice.objects.filter(organization=org)
species = get_object_or_404(Species, slug=species_slug)
adoption_notices = [adoption_notice for adoption_notice in ans_of_rescue_org if species in adoption_notice.species]
template = 'fellchensammlung/embeddables/list-adoption-notices.html'
return render(request, template, context={"adoption_notices": adoption_notices})