Skip to content

Commit

Permalink
Fix Multi Report recursion error (#3714)
Browse files Browse the repository at this point in the history
Co-authored-by: Jeroen Dekkers <[email protected]>
Co-authored-by: Jan Klopper <[email protected]>
  • Loading branch information
3 people authored Oct 30, 2024
1 parent c196b2b commit 12c5788
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 27 deletions.
3 changes: 2 additions & 1 deletion rocky/reports/views/aggregate_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.shortcuts import redirect
from django.urls import reverse
from django.utils.translation import gettext_lazy as _
from django.views.generic import TemplateView

from reports.report_types.aggregate_organisation_report.report import AggregateOrganisationReport
from reports.report_types.helpers import get_ooi_types_from_aggregate_report
Expand Down Expand Up @@ -69,7 +70,7 @@ def get_context_data(self, **kwargs):


class ReportTypesSelectionAggregateReportView(
AggregateReportStepsMixin, BreadcrumbsAggregateReportView, ReportTypeSelectionView
AggregateReportStepsMixin, BreadcrumbsAggregateReportView, ReportTypeSelectionView, TemplateView
):
"""
Shows all possible report types from a list of Objects.
Expand Down
2 changes: 1 addition & 1 deletion rocky/reports/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def get_context_data(self, **kwargs):
return context


class ReportTypeSelectionView(BaseReportView, ReportBreadcrumbs, TemplateView):
class ReportTypeSelectionView(BaseReportView, ReportBreadcrumbs):
"""
Shows report types and handles selections and requests.
"""
Expand Down
3 changes: 2 additions & 1 deletion rocky/reports/views/generate_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.shortcuts import redirect
from django.urls import reverse
from django.utils.translation import gettext_lazy as _
from django.views.generic import TemplateView

from reports.report_types.helpers import get_ooi_types_with_report
from reports.views.base import (
Expand Down Expand Up @@ -68,7 +69,7 @@ def get_context_data(self, **kwargs):


class ReportTypesSelectionGenerateReportView(
GenerateReportStepsMixin, BreadcrumbsGenerateReportView, ReportTypeSelectionView
GenerateReportStepsMixin, BreadcrumbsGenerateReportView, ReportTypeSelectionView, TemplateView
):
"""
Shows all possible report types from a list of OOIs.
Expand Down
28 changes: 4 additions & 24 deletions rocky/reports/views/multi_report.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from datetime import datetime
from typing import Any

from django.contrib import messages
from django.http import HttpRequest, HttpResponse
from django.shortcuts import redirect
from django.urls import reverse
Expand Down Expand Up @@ -63,11 +62,6 @@ class OOISelectionMultiReportView(MultiReportStepsMixin, BreadcrumbsMultiReportV
current_step = 1
ooi_types = MultiOrganizationReport.input_ooi_types

def get(self, request, *args, **kwargs):
if not self.get_ooi_selection():
messages.error(request, self.NONE_OOI_SELECTION_MESSAGE)
return self.get(request, *args, **kwargs)


class ReportTypesSelectionMultiReportView(
MultiReportStepsMixin, BreadcrumbsMultiReportView, OOISelectionView, ReportTypeSelectionView
Expand All @@ -81,12 +75,7 @@ class ReportTypesSelectionMultiReportView(
breadcrumbs_step = 4
current_step = 2
report_type = MultiOrganizationReport

def get(self, request, *args, **kwargs):
if not self.get_ooi_selection():
messages.error(request, self.NONE_OOI_SELECTION_MESSAGE)
return redirect(self.get_previous())
return self.get(request, *args, **kwargs)
ooi_types = MultiOrganizationReport.input_ooi_types


class SetupScanMultiReportView(MultiReportStepsMixin, BreadcrumbsMultiReportView, ReportPluginView):
Expand All @@ -97,11 +86,7 @@ class SetupScanMultiReportView(MultiReportStepsMixin, BreadcrumbsMultiReportView
template_name = "generate_report/setup_scan.html"
breadcrumbs_step = 5
current_step = 3

def get(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse:
if self.all_plugins_enabled():
return redirect(self.get_next())
return super().get(request, *args, **kwargs)
ooi_types = MultiOrganizationReport.input_ooi_types


class ExportSetupMultiReportView(MultiReportStepsMixin, BreadcrumbsMultiReportView, ReportFinalSettingsView):
Expand All @@ -113,13 +98,7 @@ class ExportSetupMultiReportView(MultiReportStepsMixin, BreadcrumbsMultiReportVi
breadcrumbs_step = 6
current_step = 4
report_type = MultiOrganizationReport

def get(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse:
if not self.get_report_type_ids():
messages.error(request, self.NONE_REPORT_TYPE_SELECTION_MESSAGE)
return redirect(self.get_previous())

return super().get(request, *args, **kwargs)
ooi_types = MultiOrganizationReport.input_ooi_types


class MultiReportView(BreadcrumbsMultiReportView, ReportPluginView):
Expand All @@ -129,6 +108,7 @@ class MultiReportView(BreadcrumbsMultiReportView, ReportPluginView):

template_name = "multi_report.html"
current_step = 5
ooi_types = MultiOrganizationReport.input_ooi_types

def multi_reports_for_oois(self) -> dict[str, dict[str, Any]]:
report = MultiOrganizationReport(self.octopoes_api_connector)
Expand Down

0 comments on commit 12c5788

Please sign in to comment.