Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions dojo/api_v2/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
from django.contrib.auth.models import Permission
from django.core.exceptions import ValidationError
from django.db import IntegrityError
from django.http import FileResponse, Http404, HttpResponse
from django.db.models.query import QuerySet as DjangoQuerySet
from django.http import FileResponse, HttpResponse
from django.shortcuts import get_object_or_404
from django.utils import timezone
from django_filters.rest_framework import DjangoFilterBackend
Expand Down Expand Up @@ -2814,16 +2815,19 @@ def report_generate(request, obj, options):
),
)

elif type(obj).__name__ == "CastTaggedQuerySet":
elif isinstance(obj, DjangoQuerySet):
# Support any Django QuerySet (including Tagulous CastTaggedQuerySet)
findings = report_finding_filter_class(
request.GET,
queryset=prefetch_related_findings_for_report(obj).distinct(),
)

report_name = "Finding"

else:
raise Http404
obj_type = type(obj).__name__
msg = f"Report cannot be generated for object of type {obj_type}"
logger.warning(msg)
raise ValidationError(msg)

result = {
"product_type": product_type,
Expand Down