feat: Add basic embeddable view for ans of rescue orgs
This commit is contained in:
18
src/fellchensammlung/aviews/embeddables.py
Normal file
18
src/fellchensammlung/aviews/embeddables.py
Normal 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})
|
||||
Reference in New Issue
Block a user