@@ -59,6 +59,15 @@ class FormData:
59
59
da_address : str
60
60
61
61
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
+
62
71
@dataclass
63
72
class CertificateFormData :
64
73
full_name : str
@@ -84,21 +93,6 @@ def build_zip(record_summary: RecordSummary, user_information: Dict[str, str]) -
84
93
case , charges = tuple (c for c in case .charges if c .edit_status != EditStatus .DELETE )
85
94
)
86
95
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
-
102
96
pdf_with_warnings = FormFilling ._build_pdf_for_case (case_without_deleted_charges , user_information , sid )
103
97
if pdf_with_warnings :
104
98
pdf , internal_file_name , warnings = pdf_with_warnings
@@ -199,8 +193,14 @@ def _build_pdf_for_eligible_case(
199
193
sid : str ,
200
194
) -> Tuple [PdfReader , str , List [str ]]:
201
195
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 ]))
202
199
dismissals , convictions = Case .categorize_charges (eligible_charges )
200
+ dismissed_names = [charge .name .title () for charge in dismissals ]
203
201
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 ]
204
204
conviction_dates = list (set ([charge .disposition .date .strftime ("%b %-d, %Y" ) for charge in convictions ]))
205
205
has_conviction = len (convictions ) > 0
206
206
has_dismissals = len (dismissals ) > 0
@@ -256,9 +256,15 @@ def _build_pdf_for_eligible_case(
256
256
"dismissed_arrest_dates" : "; " .join (dismissed_arrest_dates ),
257
257
"arresting_agency" : "" ,
258
258
"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 ),
259
264
}
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 )
262
268
file_name = os .path .basename (pdf_path )
263
269
pdf = PdfReader (pdf_path )
264
270
for field in pdf .Root .AcroForm .Fields :
@@ -347,3 +353,14 @@ def _build_da_address(location: str) -> str:
347
353
}
348
354
cleaned_location = location .replace (" " , "_" ).lower ()
349
355
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