-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change plugins enabling in report flwo to checkboxes #3747
base: main
Are you sure you want to change the base?
Changes from all commits
0ddb769
9c7503b
55e76da
32fe327
0cfb16a
8803173
c06d271
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
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 | ||
from django.utils.translation import gettext_lazy as _ | ||
from httpx import HTTPError | ||
from katalogus.client import get_katalogus | ||
from django.views.generic import TemplateView | ||
|
||
from reports.report_types.aggregate_organisation_report.report import AggregateOrganisationReport | ||
|
@@ -107,6 +110,21 @@ class ExportSetupAggregateReportView( | |
current_step = 4 | ||
report_type = AggregateOrganisationReport | ||
|
||
def post(self, request, *args, **kwargs): | ||
selected_plugins = request.POST.getlist("plugin", []) | ||
|
||
client = get_katalogus(self.organization.code) | ||
for selected_plugin in selected_plugins: | ||
try: | ||
client.enable_boefje_by_id(selected_plugin) | ||
except HTTPError: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hate that we bubble up the http errors from the client to here. Lets move that away asap, the katalogusclient already has some localized exceptions for other issues. |
||
messages.error( | ||
request, | ||
_("An error occurred while enabling {}. The plugin is not available.").format(selected_plugin), | ||
) | ||
return self.post(request, *args, **kwargs) | ||
return super().post(request, *args, **kwargs) | ||
|
||
|
||
class SaveAggregateReportView(SaveAggregateReportMixin, BreadcrumbsAggregateReportView, SaveReportView): | ||
""" | ||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -1,9 +1,12 @@ | ||||
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 | ||||
from django.utils.translation import gettext_lazy as _ | ||||
from httpx import HTTPError | ||||
from katalogus.client import get_katalogus | ||||
from django.views.generic import TemplateView | ||||
|
||||
from reports.views.base import ( | ||||
|
@@ -100,6 +103,21 @@ class ExportSetupGenerateReportView(GenerateReportStepsMixin, BreadcrumbsGenerat | |||
breadcrumbs_step = 6 | ||||
current_step = 4 | ||||
|
||||
def post(self, request, *args, **kwargs): | ||||
selected_plugins = request.POST.getlist("plugin", []) | ||||
|
||||
client = get_katalogus(self.organization.code) | ||||
for selected_plugin in selected_plugins: | ||||
try: | ||||
client.enable_boefje_by_id(selected_plugin) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should also check if the user has the permissions to enable these boefjes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to check permissions use this method from the nl-kat-coordination/rocky/account/mixins.py Line 167 in 193764c
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This permission checks if the user can raise the clearance level of an object right? We want to enable plugins. Shouldnt this be another permission? |
||||
except HTTPError: | ||||
messages.error( | ||||
request, | ||||
_("An error occurred while enabling {}. The plugin is not available.").format(selected_plugin), | ||||
) | ||||
return self.post(request, *args, **kwargs) | ||||
return super().post(request, *args, **kwargs) | ||||
|
||||
Comment on lines
+106
to
+120
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you move this post to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to make sure that the user knows that by checking the checkboxes that it means enable and continue There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm no I cant move it to there because these plugins are enabled only in the export step, and not taken all the way to the final step like the other settings. And the button already says: enable and continue |
||||
|
||||
class SaveGenerateReportView(SaveGenerateReportMixin, BreadcrumbsGenerateReportView, SaveReportView): | ||||
""" | ||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,8 @@ msgid "" | |
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-10-28 12:38+0000\n" | ||
|
||
"POT-Creation-Date: 2024-10-28 17:30+0000\n" | ||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | ||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
|
@@ -1595,7 +1596,6 @@ msgstr "" | |
#: onboarding/templates/account/step_2a_organization_update.html | ||
#: onboarding/templates/account/step_2b_indemnification_setup.html | ||
#: onboarding/templates/step_3d_clearance_level_introduction.html | ||
#: reports/templates/partials/report_setup_scan.html | ||
msgid "Continue" | ||
msgstr "" | ||
|
||
|
@@ -2361,7 +2361,8 @@ msgstr "" | |
msgid "Please select all required plugins to proceed." | ||
msgstr "" | ||
|
||
#: onboarding/views.py | ||
#: onboarding/views.py reports/views/aggregate_report.py | ||
#: reports/views/generate_report.py | ||
msgid "An error occurred while enabling {}. The plugin is not available." | ||
msgstr "" | ||
|
||
|
@@ -3998,6 +3999,10 @@ msgstr "" | |
msgid "There are no optional plugins." | ||
msgstr "" | ||
|
||
#: reports/templates/partials/report_setup_scan.html | ||
msgid "Enable plugins and continue" | ||
msgstr "" | ||
|
||
#: reports/templates/partials/report_severity_totals.html | ||
#: reports/templates/partials/report_severity_totals_table.html | ||
msgid "Findings overview" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be sure: The views still seem to refer to the
plugin
query parameter, so I'm unsure if this change works. Regardless, I thinkplugins
as a query parameter list would've been a better nameThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah weird right. It seems that this variable is and was not used... But I'm afraid to delete it.