Skip to content

Commit

Permalink
Small formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
tudoramariei committed Oct 7, 2024
1 parent 98e11ac commit 3ccc120
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 8 deletions.
2 changes: 1 addition & 1 deletion backend/donations/views/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def get(self, request, ngo_url, *args, **kwargs):
"ngo_upload_url": reverse("api-ngo-upload-url"),
"counties": settings.FORM_COUNTIES_NATIONAL,
"ngo": ngo,
"other_emails": ", ".join(str(x) for x in ngo.other_emails) if ngo.other_emails else "",
"other_emails": (", ".join(str(x) for x in ngo.other_emails) if ngo.other_emails else ""),
}

try:
Expand Down
45 changes: 40 additions & 5 deletions backend/donations/views/donations_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ def _package_donations(tmp_dir_name: str, donations: QuerySet[Donor], ngo: Ngo,
file_data = _download_file(source_url)
except JobDownloadError:
retries_left -= 1
logger.error("Could not download '%s'. Retries left %d.", source_url, retries_left)
logger.error(
"Could not download '%s'. Retries left %d.",
source_url,
retries_left,
)
except Exception as e:
retries_left = 0
logger.error("Could not download '%s'. Exception %s", source_url, e)
Expand Down Expand Up @@ -283,7 +287,11 @@ def _download_file(source_url: str) -> bytes:


def _generate_xml_files(
ngo: Ngo, zip_archive: ZipFile, zip_64_flag: bool, zip_timestamp: datetime, cnp_idx: Dict[str, Dict[str, Any]]
ngo: Ngo,
zip_archive: ZipFile,
zip_64_flag: bool,
zip_timestamp: datetime,
cnp_idx: Dict[str, Dict[str, Any]],
):
if not cnp_idx or not ngo or not zip_archive:
return
Expand All @@ -294,7 +302,16 @@ def _generate_xml_files(
# create a single XML file
if ngo_donations.count() < 2 * settings.DONATIONS_XML_LIMIT_PER_FILE:
xml_name: str = "d230.xml"
_build_xml(ngo, ngo_donations, 1, xml_name, cnp_idx, zip_timestamp, zip_archive, zip_64_flag)
_build_xml(
ngo,
ngo_donations,
1,
xml_name,
cnp_idx,
zip_timestamp,
zip_archive,
zip_64_flag,
)

return

Expand All @@ -316,7 +333,16 @@ def _generate_donations_by_county(cnp_idx, ngo, ngo_donations, zip_64_flag, zip_
xml_name: str = f"d230_{county_code}.xml"

county_donations: QuerySet[Donor] = ngo_donations.filter(county=current_county)
_build_xml(ngo, county_donations, xml_count, xml_name, cnp_idx, zip_timestamp, zip_archive, zip_64_flag)
_build_xml(
ngo,
county_donations,
xml_count,
xml_name,
cnp_idx,
zip_timestamp,
zip_archive,
zip_64_flag,
)
xml_count += 1
else:
for i in range(math.ceil(current_county_count / donations_limit)):
Expand All @@ -325,7 +351,16 @@ def _generate_donations_by_county(cnp_idx, ngo, ngo_donations, zip_64_flag, zip_
county_donations: QuerySet[Donor] = ngo_donations.filter(county=current_county)[
i * donations_limit : (i + 1) * donations_limit
]
_build_xml(ngo, county_donations, xml_count, xml_name, cnp_idx, zip_timestamp, zip_archive, zip_64_flag)
_build_xml(
ngo,
county_donations,
xml_count,
xml_name,
cnp_idx,
zip_timestamp,
zip_archive,
zip_64_flag,
)

xml_count += 1

Expand Down
2 changes: 1 addition & 1 deletion backend/donations/views/my_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def get(self, request: HttpRequest, *args, **kwargs):
current_year_donors: Optional[QuerySet[Donor]] = grouped_donors.get(now.year)
donors_metadata = {
"total": current_year_donors.count() if current_year_donors else 0,
"total_signed": current_year_donors.filter(has_signed=True).count() if current_year_donors else 0,
"total_signed": (current_year_donors.filter(has_signed=True).count() if current_year_donors else 0),
"years": list(grouped_donors.keys()),
}

Expand Down
2 changes: 1 addition & 1 deletion backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ filterwarnings = [

[tool.black]
line-length = 120
target-version = ["py311"]
target-version = ["py312"]
extend-exclude = '''
/(
| _appengine_legacy
Expand Down

0 comments on commit 3ccc120

Please sign in to comment.