Skip to content

Commit

Permalink
style: format ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed-Hacene committed May 14, 2024
1 parent 75bed92 commit 9be1a0c
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 48 deletions.
6 changes: 3 additions & 3 deletions backend/core/base_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
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"))
36 changes: 18 additions & 18 deletions backend/iam/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions backend/serdes/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9be1a0c

Please sign in to comment.