From 52774780ea2885b2aae1d8e228067a75fb27ebc5 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Tue, 14 May 2024 13:32:03 +0200 Subject: [PATCH 1/6] fix: anlytics stats filter --- backend/core/base_models.py | 6 ++--- backend/core/forms.py | 48 ++++++++++++++++++------------------- backend/core/helpers.py | 44 +++++++++++++++++++++++++++------- backend/core/views.py | 46 +++++++++++++++++++++++++---------- backend/iam/forms.py | 36 ++++++++++++++-------------- backend/serdes/views.py | 6 ++--- 6 files changed, 117 insertions(+), 69 deletions(-) diff --git a/backend/core/base_models.py b/backend/core/base_models.py index aae66186f..40487af17 100644 --- a/backend/core/base_models.py +++ b/backend/core/base_models.py @@ -90,9 +90,9 @@ def clean(self) -> None: if not self.is_unique_in_scope(scope=scope, fields_to_check=_fields_to_check): for field in _fields_to_check: if not self.is_unique_in_scope(scope=scope, fields_to_check=[field]): - field_errors[field] = ( - f"{getattr(self, field)} is already used in this scope. Please choose another value." - ) + field_errors[ + field + ] = f"{getattr(self, field)} is already used in this scope. Please choose another value." super().clean() if field_errors: raise ValidationError(field_errors) diff --git a/backend/core/forms.py b/backend/core/forms.py index 3c9ba9736..220cf4daf 100644 --- a/backend/core/forms.py +++ b/backend/core/forms.py @@ -80,9 +80,9 @@ def __init__(self, recommended_reference_controls=None, *args, **kwargs) -> None def get_context(self, name, value, attrs): context = super().get_context(name, value, attrs) if self.recommended_reference_controls: - context["recommended_reference_controls"] = ( - self.recommended_reference_controls - ) + context[ + "recommended_reference_controls" + ] = self.recommended_reference_controls return context @@ -127,31 +127,31 @@ def __init__(self, *args, **kwargs): f.widget.attrs["id"] = ( f"id_{model_name}_{fname}" if model_name else f"id_{fname}" ) - f.widget.attrs["class"] = ( - "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" - ) + f.widget.attrs[ + "class" + ] = "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" if input_type in select_inputs: f.widget.attrs["id"] = f"id_{model_name}_{fname}" - f.widget.attrs["autocomplete"] = ( - "off" # workaround for Firefox behavior: https://stackoverflow.com/questions/4831848/firefox-ignores-option-selected-selected - ) - f.widget.attrs["class"] = ( - "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 disabled:opacity-50" - ) + f.widget.attrs[ + "autocomplete" + ] = "off" # workaround for Firefox behavior: https://stackoverflow.com/questions/4831848/firefox-ignores-option-selected-selected + f.widget.attrs[ + "class" + ] = "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 disabled:opacity-50" if input_type == Textarea: - f.widget.attrs["class"] = ( - "block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500" - ) + f.widget.attrs[ + "class" + ] = "block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500" if input_type == CheckboxInput: f.widget.attrs["id"] = f"id_{model_name}_{fname}" - f.widget.attrs["class"] = ( - "w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500" - ) + f.widget.attrs[ + "class" + ] = "w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500" if input_type == DefaultDateInput: f.widget.attrs["id"] = f"id_{model_name}_{fname}" - f.widget.attrs["class"] = ( - "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" - ) + f.widget.attrs[ + "class" + ] = "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" if input_type == Select: self.default_if_one(fname) @@ -181,9 +181,9 @@ def __init__(self, *args, **kwargs): super(__class__, self).__init__(*args, **kwargs) for password in self.fields.items(): password[1].widget.attrs["class"] = style - self.fields["terms_service"].widget.attrs["class"] = ( - "ml-2 rounded border-gray-300 shadow-sm focus:border-indigo-600 focus:ring focus:ring-indigo-500 focus:ring-opacity-50 text-indigo-500" - ) + self.fields["terms_service"].widget.attrs[ + "class" + ] = "ml-2 rounded border-gray-300 shadow-sm focus:border-indigo-600 focus:ring focus:ring-indigo-500 focus:ring-opacity-50 text-indigo-500" self.fields["terms_service"].widget.attrs["id"] = "terms_service" terms_service = forms.BooleanField(label=_("terms and conditions of use")) diff --git a/backend/core/helpers.py b/backend/core/helpers.py index c6dbdd896..54be81166 100644 --- a/backend/core/helpers.py +++ b/backend/core/helpers.py @@ -748,15 +748,38 @@ def risks_per_project_groups(user: User): def get_counters(user: User): + print() return { - "domains": Folder.objects.filter( - content_type=Folder.ContentType.DOMAIN - ).count(), - "projects": Project.objects.all().count(), - "applied_controls": AppliedControl.objects.all().count(), - "risk_assessments": RiskAssessment.objects.all().count(), - "compliance_assessments": ComplianceAssessment.objects.all().count(), - "policies": Policy.objects.all().count(), + "domains": len( + RoleAssignment.get_accessible_object_ids( + Folder.get_root_folder(), user, Folder + )[0] + ), + "projects": len( + RoleAssignment.get_accessible_object_ids( + Folder.get_root_folder(), user, Project + )[0] + ), + "applied_controls": len( + RoleAssignment.get_accessible_object_ids( + Folder.get_root_folder(), user, AppliedControl + )[0] + ), + "risk_assessments": len( + RoleAssignment.get_accessible_object_ids( + Folder.get_root_folder(), user, RiskAssessment + )[0] + ), + "compliance_assessments": len( + RoleAssignment.get_accessible_object_ids( + Folder.get_root_folder(), user, ComplianceAssessment + )[0] + ), + "policies": len( + RoleAssignment.get_accessible_object_ids( + Folder.get_root_folder(), user, Policy + )[0] + ), } @@ -964,11 +987,14 @@ def threats_count_per_name(user: User): _, _, ) = RoleAssignment.get_accessible_object_ids(Folder.get_root_folder(), user, Threat) + viewable_scenarios = RoleAssignment.get_accessible_object_ids( + Folder.get_root_folder(), user, RiskScenario + )[0] # expected by echarts to send the threats names in labels and the count of each threat in values for threat in Threat.objects.filter(id__in=object_ids_view).order_by("name"): - val = RiskScenario.objects.filter(threats=threat).count() + val = RiskScenario.objects.filter(threats=threat).filter(id__in=viewable_scenarios).count() if val > 0: labels.append({"name": threat.name}) values.append(val) diff --git a/backend/core/views.py b/backend/core/views.py index bc70c8562..ffea66c84 100644 --- a/backend/core/views.py +++ b/backend/core/views.py @@ -283,14 +283,25 @@ def colors(self, request): @action(detail=False, name="Get used risk matrices") def used(self, request): - _used_matrices = RiskMatrix.objects.filter( - riskassessment__isnull=False - ).distinct() + viewable_matrices = RoleAssignment.get_accessible_object_ids( + Folder.get_root_folder(), request.user, RiskMatrix + )[0] + viewable_assessments = RoleAssignment.get_accessible_object_ids( + Folder.get_root_folder(), request.user, RiskAssessment + )[0] + _used_matrices = ( + RiskMatrix.objects.filter(riskassessment__isnull=False) + .filter(id__in=viewable_matrices) + .filter(riskassessment__id__in=viewable_assessments) + .distinct() + ) used_matrices = _used_matrices.values("id", "name") for i in range(len(used_matrices)): - used_matrices[i]["risk_assessments_count"] = _used_matrices.get( - id=used_matrices[i]["id"] - ).riskassessment_set.count() + used_matrices[i]["risk_assessments_count"] = ( + RiskAssessment.objects.filter(risk_matrix=_used_matrices[i].id) + .filter(id__in=viewable_assessments) + .count() + ) return Response({"results": used_matrices}) @@ -1060,14 +1071,25 @@ def tree(self, request, pk): @action(detail=False, name="Get used frameworks") def used(self, request): - _used_frameworks = Framework.objects.filter( - complianceassessment__isnull=False - ).distinct() + viewable_framework = RoleAssignment.get_accessible_object_ids( + Folder.get_root_folder(), request.user, Framework + )[0] + viewable_assessments = RoleAssignment.get_accessible_object_ids( + Folder.get_root_folder(), request.user, ComplianceAssessment + )[0] + _used_frameworks = ( + Framework.objects.filter(complianceassessment__isnull=False) + .filter(id__in=viewable_framework) + .filter(complianceassessment__id__in=viewable_assessments) + .distinct() + ) used_frameworks = _used_frameworks.values("id", "name") for i in range(len(used_frameworks)): - used_frameworks[i]["compliance_assessments_count"] = _used_frameworks.get( - id=used_frameworks[i]["id"] - ).complianceassessment_set.count() + used_frameworks[i]["compliance_assessments_count"] = ( + ComplianceAssessment.objects.filter(framework=_used_frameworks[i].id) + .filter(id__in=viewable_assessments) + .count() + ) return Response({"results": used_frameworks}) diff --git a/backend/iam/forms.py b/backend/iam/forms.py index 448875e6c..ada57867c 100644 --- a/backend/iam/forms.py +++ b/backend/iam/forms.py @@ -61,28 +61,28 @@ def __init__(self, *args, **kwargs): f.widget.attrs["id"] = ( f"id_{model_name}_{fname}" if model_name else f"id_{fname}" ) - f.widget.attrs["class"] = ( - "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" - ) + f.widget.attrs[ + "class" + ] = "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" if input_type in select_inputs: f.widget.attrs["id"] = f"id_{model_name}_{fname}" - f.widget.attrs["class"] = ( - "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" - ) + f.widget.attrs[ + "class" + ] = "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" if input_type == Textarea: - f.widget.attrs["class"] = ( - "block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500" - ) + f.widget.attrs[ + "class" + ] = "block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500" if input_type == CheckboxInput: f.widget.attrs["id"] = f"id_{model_name}_{fname}" - f.widget.attrs["class"] = ( - "w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500" - ) + f.widget.attrs[ + "class" + ] = "w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500" if input_type == DefaultDateInput: f.widget.attrs["id"] = f"id_{model_name}_{fname}" - f.widget.attrs["class"] = ( - "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" - ) + f.widget.attrs[ + "class" + ] = "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" class FolderUpdateForm(StyledModelForm): @@ -238,9 +238,9 @@ class UserPasswordChangeForm(AdminPasswordChangeForm): def __init__(self, user, *args, **kwargs): super().__init__(user, *args, **kwargs) for fname, f in self.fields.items(): - f.widget.attrs["class"] = ( - "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" - ) + f.widget.attrs[ + "class" + ] = "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" print("FNAME:", fname) self.fields.get("password1").widget.attrs["id"] = "password1" self.fields.get("password2").widget.attrs["id"] = "password2" diff --git a/backend/serdes/views.py b/backend/serdes/views.py index 4cd2cb218..3ceed8bf5 100644 --- a/backend/serdes/views.py +++ b/backend/serdes/views.py @@ -21,9 +21,9 @@ def get(self, request, *args, **kwargs): return Response(status=status.HTTP_403_FORBIDDEN) response = HttpResponse(content_type="application/json") timestamp = datetime.now().strftime("%Y%m%d-%H%M%S") - response["Content-Disposition"] = ( - f'attachment; filename="ciso-assistant-db-{timestamp}.json"' - ) + response[ + "Content-Disposition" + ] = f'attachment; filename="ciso-assistant-db-{timestamp}.json"' response.write(f'[{{"meta": [{{"media_version": "{VERSION}"}}]}},\n') # Here we dump th data to stdout From 6b3a0d42d0ea3f8cbe329ef531a189f3d39065f3 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Tue, 14 May 2024 13:37:47 +0200 Subject: [PATCH 2/6] fix: risk assessments with same name in composer --- frontend/src/routes/(app)/analytics/ComposerSelect.svelte | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/src/routes/(app)/analytics/ComposerSelect.svelte b/frontend/src/routes/(app)/analytics/ComposerSelect.svelte index 621c32138..967cd2243 100644 --- a/frontend/src/routes/(app)/analytics/ComposerSelect.svelte +++ b/frontend/src/routes/(app)/analytics/ComposerSelect.svelte @@ -15,7 +15,8 @@ onMount(async () => { const riskAssessments = await fetch('/risk-assessments').then((res) => res.json()); - options = getOptions({ objects: riskAssessments }); + console.log(riskAssessments) + options = getOptions({ objects: riskAssessments, extra_fields: [['project', 'str']] }); }); From 4e9dc3390d8b4f378d8682f1d1703877db34d953 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Tue, 14 May 2024 13:40:26 +0200 Subject: [PATCH 3/6] style: display risk assessments with context in composer --- frontend/src/routes/(app)/analytics/composer/+page.svelte | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/routes/(app)/analytics/composer/+page.svelte b/frontend/src/routes/(app)/analytics/composer/+page.svelte index 7afbb574c..cbdc02b3e 100644 --- a/frontend/src/routes/(app)/analytics/composer/+page.svelte +++ b/frontend/src/routes/(app)/analytics/composer/+page.svelte @@ -20,7 +20,7 @@ } -
+
{m.yourSelection()}
@@ -126,7 +126,7 @@ {/if}
{#if item.risk_assessment.quality_check.count > 0} From 7e45cbe587220b38d00bc4b1c378ba7776afb4c1 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Tue, 14 May 2024 13:41:20 +0200 Subject: [PATCH 4/6] chore: remove console.log --- frontend/src/routes/(app)/analytics/ComposerSelect.svelte | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/src/routes/(app)/analytics/ComposerSelect.svelte b/frontend/src/routes/(app)/analytics/ComposerSelect.svelte index 967cd2243..4309472d3 100644 --- a/frontend/src/routes/(app)/analytics/ComposerSelect.svelte +++ b/frontend/src/routes/(app)/analytics/ComposerSelect.svelte @@ -15,7 +15,6 @@ onMount(async () => { const riskAssessments = await fetch('/risk-assessments').then((res) => res.json()); - console.log(riskAssessments) options = getOptions({ objects: riskAssessments, extra_fields: [['project', 'str']] }); }); From 75bed921501935962b26a62b84bca9bdc1796101 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Tue, 14 May 2024 13:43:22 +0200 Subject: [PATCH 5/6] style: run ruff format --- backend/core/helpers.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/core/helpers.py b/backend/core/helpers.py index 54be81166..c7a7c2a4b 100644 --- a/backend/core/helpers.py +++ b/backend/core/helpers.py @@ -994,7 +994,11 @@ def threats_count_per_name(user: User): # expected by echarts to send the threats names in labels and the count of each threat in values for threat in Threat.objects.filter(id__in=object_ids_view).order_by("name"): - val = RiskScenario.objects.filter(threats=threat).filter(id__in=viewable_scenarios).count() + val = ( + RiskScenario.objects.filter(threats=threat) + .filter(id__in=viewable_scenarios) + .count() + ) if val > 0: labels.append({"name": threat.name}) values.append(val) From 9be1a0c8c3fcf9ddb9a45680b068aceaac6203b5 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Tue, 14 May 2024 13:46:17 +0200 Subject: [PATCH 6/6] style: format ruff --- backend/core/base_models.py | 6 ++--- backend/core/forms.py | 48 ++++++++++++++++++------------------- backend/iam/forms.py | 36 ++++++++++++++-------------- backend/serdes/views.py | 6 ++--- 4 files changed, 48 insertions(+), 48 deletions(-) diff --git a/backend/core/base_models.py b/backend/core/base_models.py index 40487af17..aae66186f 100644 --- a/backend/core/base_models.py +++ b/backend/core/base_models.py @@ -90,9 +90,9 @@ def clean(self) -> None: if not self.is_unique_in_scope(scope=scope, fields_to_check=_fields_to_check): for field in _fields_to_check: if not self.is_unique_in_scope(scope=scope, fields_to_check=[field]): - field_errors[ - field - ] = f"{getattr(self, field)} is already used in this scope. Please choose another value." + field_errors[field] = ( + f"{getattr(self, field)} is already used in this scope. Please choose another value." + ) super().clean() if field_errors: raise ValidationError(field_errors) diff --git a/backend/core/forms.py b/backend/core/forms.py index 220cf4daf..3c9ba9736 100644 --- a/backend/core/forms.py +++ b/backend/core/forms.py @@ -80,9 +80,9 @@ def __init__(self, recommended_reference_controls=None, *args, **kwargs) -> None def get_context(self, name, value, attrs): context = super().get_context(name, value, attrs) if self.recommended_reference_controls: - context[ - "recommended_reference_controls" - ] = self.recommended_reference_controls + context["recommended_reference_controls"] = ( + self.recommended_reference_controls + ) return context @@ -127,31 +127,31 @@ def __init__(self, *args, **kwargs): f.widget.attrs["id"] = ( f"id_{model_name}_{fname}" if model_name else f"id_{fname}" ) - f.widget.attrs[ - "class" - ] = "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" + f.widget.attrs["class"] = ( + "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" + ) if input_type in select_inputs: f.widget.attrs["id"] = f"id_{model_name}_{fname}" - f.widget.attrs[ - "autocomplete" - ] = "off" # workaround for Firefox behavior: https://stackoverflow.com/questions/4831848/firefox-ignores-option-selected-selected - f.widget.attrs[ - "class" - ] = "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 disabled:opacity-50" + f.widget.attrs["autocomplete"] = ( + "off" # workaround for Firefox behavior: https://stackoverflow.com/questions/4831848/firefox-ignores-option-selected-selected + ) + f.widget.attrs["class"] = ( + "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 disabled:opacity-50" + ) if input_type == Textarea: - f.widget.attrs[ - "class" - ] = "block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500" + f.widget.attrs["class"] = ( + "block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500" + ) if input_type == CheckboxInput: f.widget.attrs["id"] = f"id_{model_name}_{fname}" - f.widget.attrs[ - "class" - ] = "w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500" + f.widget.attrs["class"] = ( + "w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500" + ) if input_type == DefaultDateInput: f.widget.attrs["id"] = f"id_{model_name}_{fname}" - f.widget.attrs[ - "class" - ] = "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" + f.widget.attrs["class"] = ( + "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" + ) if input_type == Select: self.default_if_one(fname) @@ -181,9 +181,9 @@ def __init__(self, *args, **kwargs): super(__class__, self).__init__(*args, **kwargs) for password in self.fields.items(): password[1].widget.attrs["class"] = style - self.fields["terms_service"].widget.attrs[ - "class" - ] = "ml-2 rounded border-gray-300 shadow-sm focus:border-indigo-600 focus:ring focus:ring-indigo-500 focus:ring-opacity-50 text-indigo-500" + self.fields["terms_service"].widget.attrs["class"] = ( + "ml-2 rounded border-gray-300 shadow-sm focus:border-indigo-600 focus:ring focus:ring-indigo-500 focus:ring-opacity-50 text-indigo-500" + ) self.fields["terms_service"].widget.attrs["id"] = "terms_service" terms_service = forms.BooleanField(label=_("terms and conditions of use")) diff --git a/backend/iam/forms.py b/backend/iam/forms.py index ada57867c..448875e6c 100644 --- a/backend/iam/forms.py +++ b/backend/iam/forms.py @@ -61,28 +61,28 @@ def __init__(self, *args, **kwargs): f.widget.attrs["id"] = ( f"id_{model_name}_{fname}" if model_name else f"id_{fname}" ) - f.widget.attrs[ - "class" - ] = "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" + f.widget.attrs["class"] = ( + "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" + ) if input_type in select_inputs: f.widget.attrs["id"] = f"id_{model_name}_{fname}" - f.widget.attrs[ - "class" - ] = "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" + f.widget.attrs["class"] = ( + "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" + ) if input_type == Textarea: - f.widget.attrs[ - "class" - ] = "block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500" + f.widget.attrs["class"] = ( + "block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500" + ) if input_type == CheckboxInput: f.widget.attrs["id"] = f"id_{model_name}_{fname}" - f.widget.attrs[ - "class" - ] = "w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500" + f.widget.attrs["class"] = ( + "w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500" + ) if input_type == DefaultDateInput: f.widget.attrs["id"] = f"id_{model_name}_{fname}" - f.widget.attrs[ - "class" - ] = "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" + f.widget.attrs["class"] = ( + "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" + ) class FolderUpdateForm(StyledModelForm): @@ -238,9 +238,9 @@ class UserPasswordChangeForm(AdminPasswordChangeForm): def __init__(self, user, *args, **kwargs): super().__init__(user, *args, **kwargs) for fname, f in self.fields.items(): - f.widget.attrs[ - "class" - ] = "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" + f.widget.attrs["class"] = ( + "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" + ) print("FNAME:", fname) self.fields.get("password1").widget.attrs["id"] = "password1" self.fields.get("password2").widget.attrs["id"] = "password2" diff --git a/backend/serdes/views.py b/backend/serdes/views.py index 3ceed8bf5..4cd2cb218 100644 --- a/backend/serdes/views.py +++ b/backend/serdes/views.py @@ -21,9 +21,9 @@ def get(self, request, *args, **kwargs): return Response(status=status.HTTP_403_FORBIDDEN) response = HttpResponse(content_type="application/json") timestamp = datetime.now().strftime("%Y%m%d-%H%M%S") - response[ - "Content-Disposition" - ] = f'attachment; filename="ciso-assistant-db-{timestamp}.json"' + response["Content-Disposition"] = ( + f'attachment; filename="ciso-assistant-db-{timestamp}.json"' + ) response.write(f'[{{"meta": [{{"media_version": "{VERSION}"}}]}},\n') # Here we dump th data to stdout