Skip to content

Commit

Permalink
Merge pull request #1591 from KentShikama/kent-forms-update
Browse files Browse the repository at this point in the history
Add Certificate of mailing and update forms
  • Loading branch information
KentShikama authored Feb 3, 2022
2 parents 6c82d4b + eae0bbb commit fb55bd2
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 26 deletions.
Binary file added src/backend/expungeservice/files/certificate.pdf
Binary file not shown.
Binary file modified src/backend/expungeservice/files/oregon.pdf
Binary file not shown.
62 changes: 56 additions & 6 deletions src/backend/expungeservice/form_filling.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,21 @@ class FormData:
da_address: str


@dataclass
class CertificateFormData:
full_name: str
date_of_birth: str
phone_number: str
mailing_address: str
city: str
state: str
zip_code: str

case_name_1: str
case_name_2: str
case_name_3: str


class FormFilling:
@staticmethod
def build_zip(record_summary: RecordSummary, user_information: Dict[str, str]) -> Tuple[str, str]:
Expand All @@ -82,9 +97,49 @@ def build_zip(record_summary: RecordSummary, user_information: Dict[str, str]) -
trailer.Root.AcroForm = pdf.Root.AcroForm
writer.write(file_path, trailer=trailer)
zipfile.write(file_path, file_name)

# TODO: Extract to method
pdf = FormFilling._build_certificate_of_mailing_pdf(record_summary, user_information)
file_name = f"certificate_of_mailing.pdf"
file_path = path.join(temp_dir, file_name)
writer = PdfWriter()
writer.addpages(pdf.pages)
trailer = writer.trailer
trailer.Root.AcroForm = pdf.Root.AcroForm
writer.write(file_path, trailer=trailer)
zipfile.write(file_path, file_name)

zipfile.close()
return zip_path, zip_name

@staticmethod
def _build_certificate_of_mailing_pdf(record_summary: RecordSummary, user_information: Dict[str, str]) -> PdfReader:
case_names = list(set([case.summary.name for case in record_summary.record.cases]))
case_name_1 = case_names[0] if len(case_names) > 0 else ""
case_name_2 = case_names[1] if len(case_names) > 1 else ""
case_name_3 = case_names[2] if len(case_names) > 2 else ""

form_data_dict = {
**user_information,
"case_name_1": case_name_1,
"case_name_2": case_name_2,
"case_name_3": case_name_3,
}
form = from_dict(data_class=CertificateFormData, data=form_data_dict)
pdf_path = path.join(Path(__file__).parent, "files", f"certificate.pdf")
pdf = PdfReader(pdf_path)
for field in pdf.Root.AcroForm.Fields:
field_name = field.T.lower().replace(" ", "_").replace("(", "").replace(")", "")
field_value = getattr(form, field_name)
field.V = field_value
for page in pdf.pages:
annotations = page.get("/Annots")
if annotations:
for annotation in annotations:
annotation.update(PdfDict(AP=""))
pdf.Root.AcroForm.update(PdfDict(NeedAppearances=PdfObject("true")))
return pdf

@staticmethod
def _add_warnings(writer: PdfWriter, warnings: List[str]):
if warnings:
Expand Down Expand Up @@ -177,8 +232,7 @@ def _build_pdf_for_eligible_case(
"da_address": da_address,
}
form = from_dict(data_class=FormData, data=form_data_dict)
location = case.summary.location.lower()
pdf_path = FormFilling._build_pdf_path(location, convictions)
pdf_path = path.join(Path(__file__).parent, "files", f"oregon.pdf")
file_name = os.path.basename(pdf_path)
pdf = PdfReader(pdf_path)
for field in pdf.Root.AcroForm.Fields:
Expand Down Expand Up @@ -225,10 +279,6 @@ def _compute_field_max_length(field: PdfDict) -> int:
width = float(field.Rect[2]) - float(field.Rect[0])
return int(width * CHARACTER_WIDTH)

@staticmethod
def _build_pdf_path(location: str, convictions: List[Charge]) -> str:
return path.join(Path(__file__).parent, "files", f"oregon.pdf")

@staticmethod
def _build_da_address(location: str) -> str:
ADDRESSES = {
Expand Down
5 changes: 3 additions & 2 deletions src/backend/tests/test_form_filling.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ def test_normal_conviction_uses_multnomah_conviction_form():
with ZipFile(zip_path, "r") as zip_ref:
zip_ref.extractall(temp_dir)
for _root, _dir, files in os.walk(temp_dir):
assert len(files) == 1
assert "oregon" in files[0]
assert len(files) == 2
assert "certificate_of_mailing" in files[0]
assert "oregon" in files[1]
41 changes: 23 additions & 18 deletions src/frontend/src/components/Manual/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ class Manual extends React.Component {
</a>{" "}
in appropriate courts
</li>
<li className="mb3">
<li className="mb3">
Mail in fingerprints to Oregon State Police
</li>
</ol>
Expand Down Expand Up @@ -485,14 +485,18 @@ class Manual extends React.Component {
After you input the information, RecordSponge will generate a
.zip file with PDFs of the expungement paperwork for all of the
charges, with one PDF file for each case that has eligible
charges. RecordSponge will also generate a Request form to Oregon
State Police. You will need to complete this form manually and mail
a completed copy to Oregon State Police at:
charges. RecordSponge will also generate a Request form to
Oregon State Police. You will need to complete this form
manually and mail a completed copy to Oregon State Police at:
<span className="db pt2">
Oregon State Police, CJIS – Unit 11<br>
ATTN: SET ASIDE<br>
P.O. Box 4395<br>
Portland, OR 97208-4395<br>
Oregon State Police, CJIS – Unit 11
<br />
ATTN: SET ASIDE
<br />
P.O. Box 4395
<br />
Portland, OR 97208-4395
<br />
</span>
</p>
<h3 className="f4 fw7 mb2" id="fingerprints">
Expand Down Expand Up @@ -522,16 +526,17 @@ class Manual extends React.Component {
Mail Fingerprints to OSP
</h3>
<p className="mb3">
Included in your expungement packet should be a form titled:
"Oregon State Police REQUEST FOR SET ASIDE CRIMINAL RECORD CHECK."
Fill out the sections titled "Other Names You are Known By,"
"Circuit or Municipal Court," and check the box corresponding to whether
you are seeking an expungement for a conviction or only arresets.
Included in your expungement packet should be a form titled:
"Oregon State Police REQUEST FOR SET ASIDE CRIMINAL RECORD
CHECK." Fill out the sections titled "Other Names You are Known
By," "Circuit or Municipal Court," and check the box
corresponding to whether you are seeking an expungement for a
conviction or only arresets.
</p>
<p className="mb3">
If you are seeking expungement of at least one conviction, you
will need to include a check or money order made out to
"Oregon State Police" for $33.
If you are seeking expungement of at least one conviction, you
will need to include a check or money order made out to "Oregon
State Police" for $33.
</p>
<h3 className="f4 fw7 mb2" id="filepaperwork">
File Paperwork
Expand All @@ -550,8 +555,8 @@ class Manual extends React.Component {
</li>
<li className="mb2">
After filing with the Clerk of Court, you will receive two
copies. Serve the District Attorney’s office with one of those copies.

copies. Serve the District Attorney’s office with one of those
copies.
</li>
</ul>
<h3 className="f4 fw7 mb2">Next Steps</h3>
Expand Down

0 comments on commit fb55bd2

Please sign in to comment.