Skip to content

Commit

Permalink
🎨 [#974] fixed black formatting issue
Browse files Browse the repository at this point in the history
  • Loading branch information
bart-maykin committed Jan 30, 2024
1 parent 4be6521 commit 05776f3
Show file tree
Hide file tree
Showing 15 changed files with 50 additions and 34 deletions.
6 changes: 3 additions & 3 deletions src/sdg/accounts/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ class AuthenticationForm(_AuthenticationForm):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.error_messages[
"invalid_login"
] = "Voer een juist e-mailadres en wachtwoord in."
self.error_messages["invalid_login"] = (
"Voer een juist e-mailadres en wachtwoord in."
)
2 changes: 2 additions & 0 deletions src/sdg/conf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
"django_filters",
"vng_api_common",
"vng_api_common.authorizations",
"simple_certmanager",
"drf_spectacular",
"rest_framework",
"timeline_logger",
Expand Down Expand Up @@ -159,6 +160,7 @@
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"axes.middleware.AxesMiddleware",
"django_otp.middleware.OTPMiddleware",
"allauth.account.middleware.AccountMiddleware",
]

ROOT_URLCONF = "sdg.urls"
Expand Down
1 change: 1 addition & 0 deletions src/sdg/conf/ci.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Continuous integration settings module.
"""

import os

os.environ.setdefault("IS_HTTPS", "no")
Expand Down
1 change: 1 addition & 0 deletions src/sdg/conf/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Tweaks the base settings so that caching mechanisms are used where possible,
and HTTPS is leveraged where possible to further secure things.
"""

import os

os.environ.setdefault("ENVIRONMENT", "production")
Expand Down
1 change: 1 addition & 0 deletions src/sdg/conf/staging.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Staging environment settings module.
This *should* be nearly identical to production.
"""

import os

os.environ.setdefault("ENVIRONMENT", "staging")
Expand Down
1 change: 1 addition & 0 deletions src/sdg/conf/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Staging environment settings module.
This *should* be nearly identical to production.
"""

import os

os.environ.setdefault("ENVIRONMENT", "test")
Expand Down
4 changes: 2 additions & 2 deletions src/sdg/conf/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from django.conf import settings

import pydantic
from functools import lru_cache
from decouple import Csv, config as _config, undefined
from sentry_sdk.integrations import DidNotEnable, django, redis

Expand Down Expand Up @@ -58,7 +58,7 @@ def get_sentry_integrations() -> list:
return [*default, *extra]


@pydantic.tools.lru_cache
@lru_cache
def org_type_cfg():
"""
Get the organization type configuration for the current environment.
Expand Down
8 changes: 5 additions & 3 deletions src/sdg/core/forms/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ def __init__(self, base_field, **kwargs):

kwargs.setdefault(
"widget",
DynamicArrayWidget(subwidget_form=subwidget_form)
if subwidget_form
else DynamicArrayWidget,
(
DynamicArrayWidget(subwidget_form=subwidget_form)
if subwidget_form
else DynamicArrayWidget
),
)
super().__init__(**kwargs)

Expand Down
13 changes: 9 additions & 4 deletions src/sdg/core/management/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ def load_government_organisations(data: List[Dict[str, Any]]) -> int:
owms_identifier=resource_id,
defaults={
"owms_pref_label": obj.get("prefLabel"),
"owms_end_date": string_to_date(obj.get("endDate"), "%Y-%m-%d")
if obj.get("endDate")
else None,
"owms_end_date": (
string_to_date(obj.get("endDate"), "%Y-%m-%d")
if obj.get("endDate")
else None
),
},
)
if created:
Expand Down Expand Up @@ -248,7 +250,10 @@ def _try_delete_generic_product(generic_product):

generic_products = []
for group in groups:
(generic_product, g_created,) = GeneriekProduct.objects.get_or_create(
(
generic_product,
g_created,
) = GeneriekProduct.objects.get_or_create(
upn=upn,
doelgroep=group,
)
Expand Down
2 changes: 1 addition & 1 deletion src/sdg/core/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_consultant_user_can_visit_home_page(self):
@override_settings(SDG_ORGANIZATION_TYPE="waterauthority")
def test_organization_type_link_is_displayed(self):
response = self.app.get(reverse(HOME_URL))
self.assertIn(org_type_cfg().url, response.text)
self.assertIn(str(org_type_cfg().url), response.text)

@override_settings(SDG_ORGANIZATION_TYPE="waterauthority")
def test_organization_type_logo_is_displayed(self):
Expand Down
10 changes: 5 additions & 5 deletions src/sdg/producten/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ def __init__(self, *args, **kwargs):
else:
for form in self.forms:
if not form.initial["product_titel_decentraal"]:
form.initial[
"product_titel_decentraal"
] = self.instance.product.generiek_product.vertalingen.get(
taal=form.instance.taal
).product_titel
form.initial["product_titel_decentraal"] = (
self.instance.product.generiek_product.vertalingen.get(
taal=form.instance.taal
).product_titel
)

def clean(self):
"""
Expand Down
24 changes: 12 additions & 12 deletions src/sdg/producten/tests/test_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@ def test_concept_save_now_with_default_explanation_placeholder(self):

for idx, language in enumerate(TaalChoices.get_available_languages()):
response.form[f"vertalingen-{idx}-product_aanwezig_toelichting"] = "test"
response.form[
f"vertalingen-{idx}-product_valt_onder_toelichting"
] = falls_under_explanation_map.get(language)
response.form[f"vertalingen-{idx}-product_valt_onder_toelichting"] = (
falls_under_explanation_map.get(language)
)

response = self._submit_product_form(response.form, Product.status.PUBLISHED)
self.assertEqual(response.status_code, 302)
Expand Down Expand Up @@ -435,9 +435,9 @@ def test_unable_to_save_product_with_placeholder(self):
for date_field in response.form.fields["date"]:
date_field.value = NOW_DATE

response.form[
"vertalingen-0-product_titel_decentraal"
] = "Title [[placeholder]]"
response.form["vertalingen-0-product_titel_decentraal"] = (
"Title [[placeholder]]"
)

response = response.form.submit(name="publish", value="date")
self.assertEqual(response.status_code, 200)
Expand Down Expand Up @@ -473,9 +473,9 @@ def test_able_to_save_product_concept_with_placeholder(self):
for date_field in response.form.fields["date"]:
date_field.value = None

response.form[
"vertalingen-0-product_titel_decentraal"
] = "Title [[placeholder]]"
response.form["vertalingen-0-product_titel_decentraal"] = (
"Title [[placeholder]]"
)

response = response.form.submit(name="publish", value="concept")
self.assertEqual(response.status_code, 302)
Expand Down Expand Up @@ -1395,9 +1395,9 @@ def test_able_to_save_reference_product_with_placeholder(self):
for date_field in response.form.fields["date"]:
date_field.value = NOW_DATE

response.form[
"vertalingen-0-product_titel_decentraal"
] = "Title [[placeholder]]"
response.form["vertalingen-0-product_titel_decentraal"] = (
"Title [[placeholder]]"
)

response = response.form.submit(name="publish", value="date")
self.assertEqual(response.status_code, 302)
Expand Down
6 changes: 3 additions & 3 deletions src/sdg/producten/views/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,9 @@ def get_context_data(self, **kwargs):
], # TODO: optimize
)

context[
"published_product_language_links"
] = self._get_published_taal_product_links()
context["published_product_language_links"] = (
self._get_published_taal_product_links()
)

context["history"] = (
self.product.get_all_versions()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ def handle(self, **options):
retrieved_upn_uris = [p["upnUri"] for p in products]
LocalizedGeneriekProduct.objects.filter(
generiek_product__doelgroep=service_config.doelgroep,
).exclude(generiek_product__upn__upn_uri__in=retrieved_upn_uris,).update(
).exclude(
generiek_product__upn__upn_uri__in=retrieved_upn_uris,
).update(
# Don't clean everything to prevent manually entered texts from
# being wiped.
#
Expand Down
1 change: 1 addition & 0 deletions src/sdg/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
do NOT import anything Django related here, as this file needs to be loaded
before Django is initialized.
"""

import os

from dotenv import load_dotenv
Expand Down

0 comments on commit 05776f3

Please sign in to comment.