@@ -59,6 +59,15 @@ class FormData:
5959 da_address : str
6060
6161
62+ @dataclass
63+ class FormDataWithOrder (FormData ):
64+ arrest_dates_all : str
65+ charges_all : str
66+ conviction_charges : str
67+ dismissed_charges : str
68+ dismissed_dates : str
69+
70+
6271@dataclass
6372class CertificateFormData :
6473 full_name : str
@@ -84,21 +93,6 @@ def build_zip(record_summary: RecordSummary, user_information: Dict[str, str]) -
8493 case , charges = tuple (c for c in case .charges if c .edit_status != EditStatus .DELETE )
8594 )
8695
87- # Douglas and Umatilla counties explicitly want the "Order" part of the old forms too.
88- if case .summary .location .lower () in ["douglas" , "umatilla" ]:
89- pdf_with_warnings = OldFormFilling ._build_pdf_for_case (case_without_deleted_charges , user_information )
90- if pdf_with_warnings :
91- pdf , internal_file_name , warnings = pdf_with_warnings
92- file_name = f"order_{ case_without_deleted_charges .summary .name } _{ case_without_deleted_charges .summary .case_number } _{ internal_file_name } "
93- file_path = path .join (temp_dir , file_name )
94- writer = PdfWriter ()
95- writer .addpages (pdf .pages )
96- FormFilling ._add_warnings (writer , warnings )
97- trailer = writer .trailer
98- trailer .Root .AcroForm = pdf .Root .AcroForm
99- writer .write (file_path , trailer = trailer )
100- zipfile .write (file_path , file_name )
101-
10296 pdf_with_warnings = FormFilling ._build_pdf_for_case (case_without_deleted_charges , user_information , sid )
10397 if pdf_with_warnings :
10498 pdf , internal_file_name , warnings = pdf_with_warnings
@@ -199,8 +193,14 @@ def _build_pdf_for_eligible_case(
199193 sid : str ,
200194 ) -> Tuple [PdfReader , str , List [str ]]:
201195 warnings : List [str ] = []
196+ charges = case .charges
197+ charge_names = [charge .name .title () for charge in charges ]
198+ arrest_dates_all = list (set ([charge .date .strftime ("%b %-d, %Y" ) for charge in charges ]))
202199 dismissals , convictions = Case .categorize_charges (eligible_charges )
200+ dismissed_names = [charge .name .title () for charge in dismissals ]
203201 dismissed_arrest_dates = list (set ([charge .date .strftime ("%b %-d, %Y" ) for charge in dismissals ]))
202+ dismissed_dates = list (set ([charge .disposition .date .strftime ("%b %-d, %Y" ) for charge in dismissals ]))
203+ conviction_names = [charge .name .title () for charge in convictions ]
204204 conviction_dates = list (set ([charge .disposition .date .strftime ("%b %-d, %Y" ) for charge in convictions ]))
205205 has_conviction = len (convictions ) > 0
206206 has_dismissals = len (dismissals ) > 0
@@ -256,9 +256,15 @@ def _build_pdf_for_eligible_case(
256256 "dismissed_arrest_dates" : "; " .join (dismissed_arrest_dates ),
257257 "arresting_agency" : "" ,
258258 "da_address" : da_address ,
259+ "arrest_dates_all" : "; " .join (arrest_dates_all ),
260+ "charges_all" : "; " .join (charge_names ),
261+ "conviction_charges" : "; " .join (conviction_names ),
262+ "dismissed_charges" : "; " .join (dismissed_names ),
263+ "dismissed_dates" : "; " .join (dismissed_dates ),
259264 }
260- form = from_dict (data_class = FormData , data = form_data_dict )
261- pdf_path = path .join (Path (__file__ ).parent , "files" , f"oregon.pdf" )
265+ form = from_dict (data_class = FormDataWithOrder , data = form_data_dict )
266+ location = case .summary .location .lower ()
267+ pdf_path = FormFilling ._build_pdf_path (location , convictions )
262268 file_name = os .path .basename (pdf_path )
263269 pdf = PdfReader (pdf_path )
264270 for field in pdf .Root .AcroForm .Fields :
@@ -347,3 +353,14 @@ def _build_da_address(location: str) -> str:
347353 }
348354 cleaned_location = location .replace (" " , "_" ).lower ()
349355 return ADDRESSES .get (cleaned_location , "" )
356+
357+ @staticmethod
358+ def _build_pdf_path (location : str , convictions : List [Charge ]) -> str :
359+ # Douglas and Umatilla counties explicitly want the "Order" part of the old forms too.
360+ if location in ["douglas" , "umatilla" ]:
361+ if convictions :
362+ return path .join (Path (__file__ ).parent , "files" , "oregon_with_conviction_order.pdf" )
363+ else :
364+ return path .join (Path (__file__ ).parent , "files" , "oregon_with_arrest_order.pdf" )
365+ else :
366+ return path .join (Path (__file__ ).parent , "files" , "oregon.pdf" )
0 commit comments