Skip to content

Commit db6c2cc

Browse files
committed
files using shared form are still named by county
1 parent 60043fa commit db6c2cc

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/backend/expungeservice/form_filling.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ def build_zip(record_summary: RecordSummary, user_information: Dict[str, str]) -
9595

9696
pdf_with_warnings = FormFilling._build_pdf_for_case(case_without_deleted_charges, user_information, sid)
9797
if pdf_with_warnings:
98-
pdf, internal_file_name, warnings = pdf_with_warnings
99-
file_name = f"{case_without_deleted_charges.summary.name}_{case_without_deleted_charges.summary.case_number}_{internal_file_name}"
98+
pdf, base_file_name, warnings = pdf_with_warnings
99+
file_name = f"{case_without_deleted_charges.summary.name}_{case_without_deleted_charges.summary.case_number}_{base_file_name}"
100100
file_path = path.join(temp_dir, file_name)
101101
writer = PdfWriter()
102102
writer.addpages(pdf.pages)
@@ -265,7 +265,8 @@ def _build_pdf_for_eligible_case(
265265
form = from_dict(data_class=FormDataWithOrder, data=form_data_dict)
266266
location = case.summary.location.lower()
267267
pdf_path = FormFilling._build_pdf_path(location, convictions)
268-
file_name = os.path.basename(pdf_path)
268+
base_file_name = FormFilling._build_base_file_name(location, convictions)
269+
file_name = os.path.basename(base_file_name)
269270
pdf = PdfReader(pdf_path)
270271
for field in pdf.Root.AcroForm.Fields:
271272
field_name = field.T.lower().replace(" ", "_").replace("(", "").replace(")", "")
@@ -364,3 +365,14 @@ def _build_pdf_path(location: str, convictions: List[Charge]) -> str:
364365
return path.join(Path(__file__).parent, "files", "oregon_with_arrest_order.pdf")
365366
else:
366367
return path.join(Path(__file__).parent, "files", "oregon.pdf")
368+
369+
@staticmethod
370+
def _build_base_file_name(location: str, convictions: List[Charge]) -> str:
371+
# Douglas and Umatilla counties explicitly want the "Order" part of the old forms too.
372+
if location in ["douglas", "umatilla"]:
373+
if convictions:
374+
return path.join(Path(__file__).parent, "files", f"{location}_with_conviction_order.pdf")
375+
else:
376+
return path.join(Path(__file__).parent, "files", f"{location}_with_arrest_order.pdf")
377+
else:
378+
return path.join(Path(__file__).parent, "files", f"{location}.pdf")

0 commit comments

Comments
 (0)