Skip to content

Commit

Permalink
Automated changes from black.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathangreen committed Feb 9, 2024
1 parent 4d2dfb2 commit 0b7d799
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 25 deletions.
6 changes: 3 additions & 3 deletions tests/admin/test_library_admin_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ def _add_library_states_data(
"library_email_domains-INITIAL_FORMS": 0,
"library_email_domains-MIN_NUM_FORMS": 0,
"library_email_domains-MAX_NUM_FORMS": 1000,
"library_email_domains-__prefix__-library": library.id
if library
else "",
"library_email_domains-__prefix__-library": (
library.id if library else ""
),
}
)

Expand Down
8 changes: 5 additions & 3 deletions tests/views/test_card_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,11 @@ def test_card_request_bad_data(self):
self.assertFormError(
resp.context["form"],
field,
errors + ["First name is mandatory"]
if field == "first_name"
else errors,
(
errors + ["First name is mandatory"]
if field == "first_name"
else errors
),
)

def test_card_request_no_patron_address(self):
Expand Down
3 changes: 2 additions & 1 deletion tests/views/test_verification_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ def test_no_password_form(self):
def test_password_set_post(self):
"""Is the password set on a post to the verification form
This sounds funny, but the password set form is on the email verification page
because a user may be created without a password, and will subsequently require a password to log in"""
because a user may be created without a password, and will subsequently require a password to log in
"""
user = self._default_user
token = Tokens.generate(
TokenTypes.EMAIL_VERIFICATION, expires_in_days=1, email=user.email
Expand Down
3 changes: 2 additions & 1 deletion virtual_library_card/geoloc.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ class PostProcess:
@classmethod
def mapquest_reverse_geocode(cls, data: dict) -> None:
"""Some mapquest data is different than what we expect the hierarchy to be.
Eg. US territories are treated as countries on their own, they should be under the US Country."""
Eg. US territories are treated as countries on their own, they should be under the US Country.
"""
if (
len(data.get("results", [])) < 1
or len(locations := data["results"][0].get("locations", [])) < 1
Expand Down
1 change: 1 addition & 0 deletions virtual_library_card/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.conf import settings
from django.conf.urls.static import static
from django.urls import include, path
Expand Down
12 changes: 6 additions & 6 deletions virtuallibrarycard/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,9 @@ def change_view(
"""Overridden to add the password reset url extra context"""
user = LibraryCard.objects.get(id=object_id).user
if user:
extra_context[
"reset_password_url"
] = f"../../../customuser/{user.id}/password"
extra_context["reset_password_url"] = (
f"../../../customuser/{user.id}/password"
)
return super().change_view(request, object_id, form_url, extra_context)


Expand Down Expand Up @@ -524,9 +524,9 @@ def export_users_by_consent(request: HttpRequest):

content.seek(0)
response = StreamingHttpResponse(content, content_type="text/csv")
response[
"Content-Disposition"
] = f"attachment; filename=consented_users_{consent_type}_{datetime.datetime.now()}.csv"
response["Content-Disposition"] = (
f"attachment; filename=consented_users_{consent_type}_{datetime.datetime.now()}.csv"
)
return response


Expand Down
3 changes: 2 additions & 1 deletion virtuallibrarycard/business_rules/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def _place_hierarchy_match(
country: str = None,
) -> bool:
"""Test from the current place all the way to the last parent available.
All levels of the place hierarchy MUST match even if the value isn't provided in the keyword args."""
All levels of the place hierarchy MUST match even if the value isn't provided in the keyword args.
"""
match_types = {
Place.Types.COUNTRY: country,
Place.Types.STATE: state,
Expand Down
3 changes: 2 additions & 1 deletion virtuallibrarycard/business_rules/library_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ def iter_clean_lines(io: IO) -> Generator[str, None, None]:
"""Iterate over an IO object and ignore blank lines
This is to specifically ignore empty last lines in csvs
decoding is done through charset detection
This handles unicode BOM characters since we do not control how the browser might read the file"""
This handles unicode BOM characters since we do not control how the browser might read the file
"""
# Detect charset and the decode entire file
detectline = io.read(128)
io.seek(0)
Expand Down
12 changes: 6 additions & 6 deletions virtuallibrarycard/forms/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,12 @@ def __init__(self, *args, **kwargs):
if (
instance and not instance.place
): # Edition just after creation form with minimal fields
self.fields[
"email"
].widget.value_from_datadict = lambda *args: self.instance.email
self.fields[
"first_name"
].widget.value_from_datadict = lambda *args: self.instance.first_name
self.fields["email"].widget.value_from_datadict = (
lambda *args: self.instance.email
)
self.fields["first_name"].widget.value_from_datadict = (
lambda *args: self.instance.first_name
)
self.fields["email"].widget.attrs["disabled"] = True

except KeyError as e:
Expand Down
6 changes: 3 additions & 3 deletions virtuallibrarycard/views/views_library_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ def get_form_kwargs(self):

def get_context_data(self, *args, **kwargs):
context = super().get_context_data(**kwargs)
context[
"patron_address_mandatory"
] = self.model.library.patron_address_mandatory
context["patron_address_mandatory"] = (
self.model.library.patron_address_mandatory
)
return context

def get_success_url(self):
Expand Down

0 comments on commit 0b7d799

Please sign in to comment.