diff --git a/src/backend/expungeservice/files/certificate_of_mailing.pdf b/src/backend/expungeservice/files/OSP_Form.pdf similarity index 100% rename from src/backend/expungeservice/files/certificate_of_mailing.pdf rename to src/backend/expungeservice/files/OSP_Form.pdf diff --git a/src/backend/expungeservice/form_filling.py b/src/backend/expungeservice/form_filling.py index e8899da78..5acca5e70 100644 --- a/src/backend/expungeservice/form_filling.py +++ b/src/backend/expungeservice/form_filling.py @@ -95,8 +95,8 @@ def build_zip(record_summary: RecordSummary, user_information: Dict[str, str]) - pdf_with_warnings = FormFilling._build_pdf_for_case(case_without_deleted_charges, user_information, sid) if pdf_with_warnings: - pdf, internal_file_name, warnings = pdf_with_warnings - file_name = f"{case_without_deleted_charges.summary.name}_{case_without_deleted_charges.summary.case_number}_{internal_file_name}" + pdf, base_file_name, warnings = pdf_with_warnings + file_name = f"{case_without_deleted_charges.summary.name}_{case_without_deleted_charges.summary.case_number}_{base_file_name}" file_path = path.join(temp_dir, file_name) writer = PdfWriter() writer.addpages(pdf.pages) @@ -108,7 +108,7 @@ def build_zip(record_summary: RecordSummary, user_information: Dict[str, str]) - # TODO: Extract to method pdf = FormFilling._build_certificate_of_mailing_pdf(user_information) - file_name = f"certificate_of_mailing.pdf" + file_name = f"OSP_Form.pdf" file_path = path.join(temp_dir, file_name) writer = PdfWriter() writer.addpages(pdf.pages) @@ -137,7 +137,7 @@ def _unify_sids(record_summary: RecordSummary) -> str: @staticmethod def _build_certificate_of_mailing_pdf(user_information: Dict[str, str]) -> PdfReader: form = from_dict(data_class=CertificateFormData, data=user_information) - pdf_path = path.join(Path(__file__).parent, "files", f"certificate_of_mailing.pdf") + pdf_path = path.join(Path(__file__).parent, "files", f"OSP_Form.pdf") pdf = PdfReader(pdf_path) for field in pdf.Root.AcroForm.Fields: field_name = field.T.lower().replace(" ", "_").replace("(", "").replace(")", "") @@ -265,7 +265,8 @@ def _build_pdf_for_eligible_case( form = from_dict(data_class=FormDataWithOrder, data=form_data_dict) location = case.summary.location.lower() pdf_path = FormFilling._build_pdf_path(location, convictions) - file_name = os.path.basename(pdf_path) + base_file_name = FormFilling._build_base_file_name(location, convictions) + file_name = os.path.basename(base_file_name) pdf = PdfReader(pdf_path) for field in pdf.Root.AcroForm.Fields: field_name = field.T.lower().replace(" ", "_").replace("(", "").replace(")", "") @@ -364,3 +365,14 @@ def _build_pdf_path(location: str, convictions: List[Charge]) -> str: return path.join(Path(__file__).parent, "files", "oregon_with_arrest_order.pdf") else: return path.join(Path(__file__).parent, "files", "oregon.pdf") + + @staticmethod + def _build_base_file_name(location: str, convictions: List[Charge]) -> str: + # Douglas and Umatilla counties explicitly want the "Order" part of the old forms too. + if location in ["douglas", "umatilla"]: + if convictions: + return path.join(Path(__file__).parent, "files", f"{location}_with_conviction_order.pdf") + else: + return path.join(Path(__file__).parent, "files", f"{location}_with_arrest_order.pdf") + else: + return path.join(Path(__file__).parent, "files", f"{location}.pdf")