Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change petition titles to new AOC format #490

Merged
merged 1 commit into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions dear_petition/petition/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@
ADULT_FELONIES,
ADULT_MISDEMEANORS,
)
STATUTES = {
DISMISSED: "146(a)",
NOT_GUILTY: "146(a2)",
UNDERAGED_CONVICTIONS: "145.8A",
ADULT_FELONIES: "145.5F",
ADULT_MISDEMEANORS: "145.5M",
}

SEVERITIES = Choices(
("TRAFFIC", "Traffic"),
Expand Down
10 changes: 10 additions & 0 deletions dear_petition/petition/tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import pytz
import pytest
from django.utils.timezone import make_aware, utc
from datetime import datetime, date

from dear_petition.petition import utils as pu

from ..constants import DATETIME_FORMAT

pytestmark = pytest.mark.django_db
robert-w-gries marked this conversation as resolved.
Show resolved Hide resolved


def test_dt_obj_to_date(settings):
"""Should receive only datetime objects to be converted into dates
Expand Down Expand Up @@ -114,3 +117,10 @@ def test_get_truncation_point_of_short_text_by_pixel_size():
text = "Lorem ipsum"
truncation_point = pu.get_truncation_point_of_text_by_pixel_size(text, 20000)
assert truncation_point == len(text)


def test_get_petition_filename(petition):
case_number = "12345"
date = "2020-01-01"
petitioner_name = "Test"
assert pu.get_petition_filename(petitioner_name, petition, 'pdf') == '07-28-2024 DURHAM DC 146(a) Test.pdf'
11 changes: 4 additions & 7 deletions dear_petition/petition/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.utils import timezone
from django.db.models import IntegerField, Case, When, Value
from django.db.models.functions import Cast, Substr, Concat
from .constants import DATE_FORMAT
from .constants import DATE_FORMAT, STATUTES

from PIL import ImageFont
import dateutil.parser
Expand Down Expand Up @@ -84,12 +84,9 @@ def remove_prefix(text, prefix):


def get_petition_filename(petitioner_name, petition, extension, addendum_document=None):
form_type = (
f"{petition.form_type} {addendum_document.form_type}"
if addendum_document is not None
else petition.form_type
)
return f"{petitioner_name} - {form_type} - {petition.jurisdiction} {petition.county}.{extension}"
date_generated = petition.created.date().strftime("%m-%d-%Y")
statute = STATUTES.get(petition.form_type)
return f"{date_generated} {petition.county} {petition.jurisdiction}C {statute} {petitioner_name}.{extension}"


def split_first_and_last_name(name):
Expand Down
Loading