Skip to content

Commit

Permalink
chore: Run formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
nas-tabchiche committed Apr 23, 2024
1 parent f56ca30 commit cceaa12
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 52 deletions.
1 change: 1 addition & 0 deletions backend/ciso_assistant/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""

from django.urls import include, path
from drf_spectacular.views import (
SpectacularAPIView,
Expand Down
6 changes: 3 additions & 3 deletions backend/core/base_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,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)
Expand Down
48 changes: 24 additions & 24 deletions backend/core/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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"))
42 changes: 22 additions & 20 deletions backend/iam/forms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
""" this module contains forms related to iam app
"""
"""this module contains forms related to iam app"""

from django.forms import (
CheckboxInput,
DateInput,
Expand Down Expand Up @@ -61,32 +61,33 @@ 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):
"""form to update a folder"""

# pragma pylint: disable=no-member

class Meta:
Expand Down Expand Up @@ -194,6 +195,7 @@ class Meta:

class MyProfileUpdateForm(UserChangeForm, StyledModelForm):
"""form for logged user"""

# TODO: not sure this section is useful, self user could be in user list with a mention "me"

def __init__(self, *args, user, **kwargs):
Expand Down Expand Up @@ -236,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"
Expand Down
4 changes: 2 additions & 2 deletions backend/iam/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
""" IAM model for CISO Assistant
Inspired from Azure IAM model """
"""IAM model for CISO Assistant
Inspired from Azure IAM model"""

from collections import defaultdict
from typing import Any, List, Self, Tuple
Expand Down
1 change: 1 addition & 0 deletions backend/manage.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""

import os
import sys

Expand Down
6 changes: 3 additions & 3 deletions backend/serdes/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ def is_admin_check(user):
def dump_db_view(request):
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
Expand Down

0 comments on commit cceaa12

Please sign in to comment.