Skip to content

Commit

Permalink
feat(criminal pacer data): Adds data models for criminal pacer data.
Browse files Browse the repository at this point in the history
Partially addresses: freelawproject/recap#230
  • Loading branch information
mlissner committed May 12, 2018
1 parent ca86326 commit 0310b47
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 1 deletion.
51 changes: 51 additions & 0 deletions cl/people_db/migrations/0037_add_criminal_data_fields.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('people_db', '0036_remove_unique_constraint_on_party_name'),
]

operations = [
migrations.CreateModel(
name='CriminalComplaint',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.TextField(help_text=b"The name of the criminal complaint, for example, '8:1326 Reentry of Deported Alien'")),
('disposition', models.TextField(help_text=b'The disposition of the criminal complaint.')),
],
),
migrations.CreateModel(
name='CriminalCount',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.TextField(help_text=b"The name of the count, such as '21:952 and 960 - Importation of Marijuana(1)'.")),
('disposition', models.TextField(help_text=b"The disposition of the count, such as 'Custody of BOP for 60 months, followed by 4 years supervised release. No fine. $100 penalty assessment.", blank=True)),
('status', models.SmallIntegerField(help_text=b'Whether the count is pending or terminated.', choices=[(1, b'Pending'), (2, b'Terminated')])),
],
),
migrations.AddField(
model_name='partytype',
name='highest_offense_level_opening',
field=models.TextField(help_text=b'In a criminal case, the highest offense level at the opening of the case.', blank=True),
),
migrations.AddField(
model_name='partytype',
name='highest_offense_level_terminated',
field=models.TextField(help_text=b'In a criminal case, the highest offense level at the end of the case.', blank=True),
),
migrations.AddField(
model_name='criminalcount',
name='party_type',
field=models.ForeignKey(related_name='criminal_counts', to='people_db.PartyType', help_text=b'The docket and party the counts are associated with.'),
),
migrations.AddField(
model_name='criminalcomplaint',
name='party_type',
field=models.ForeignKey(related_name='criminal_complaints', to='people_db.PartyType', help_text=b'The docket and party the complaints are associated with.'),
),
]
71 changes: 70 additions & 1 deletion cl/people_db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
validate_at_most_n,
validate_supervisor,
)
from cl.lib.search_index_utils import solr_list, null_map, normalize_search_dicts
from cl.lib.search_index_utils import solr_list, null_map, \
normalize_search_dicts
from cl.lib.storage import IncrementingFileSystemStorage
from cl.lib.string_utils import trunc
from cl.search.models import Court
Expand Down Expand Up @@ -1284,6 +1285,16 @@ class PartyType(models.Model):
help_text="Additional info from PACER",
db_index=True,
)
highest_offense_level_opening = models.TextField(
help_text="In a criminal case, the highest offense level at the "
"opening of the case.",
blank=True,
)
highest_offense_level_terminated = models.TextField(
help_text="In a criminal case, the highest offense level at the end "
"of the case.",
blank=True,
)

class Meta:
unique_together = ('docket', 'party', 'name')
Expand All @@ -1297,6 +1308,64 @@ def __unicode__(self):
)


class CriminalCount(models.Model):
"""The criminal counts associated with a PartyType object (i.e., associated
with a party in a docket.
"""
PENDING = 1
TERMINATED = 2
COUNT_STATUSES = (
(PENDING, "Pending"),
(TERMINATED, "Terminated"),
)
party_type = models.ForeignKey(
PartyType,
help_text="The docket and party the counts are associated with.",
related_name="criminal_counts",
)
name = models.TextField(
help_text="The name of the count, such as '21:952 and 960 - "
"Importation of Marijuana(1)'.",
)
disposition = models.TextField(
help_text="The disposition of the count, such as 'Custody of BOP for "
"60 months, followed by 4 years supervised release. No "
"fine. $100 penalty assessment.",
# Can be blank if no disposition yet.
blank=True,
)
status = models.SmallIntegerField(
help_text="Whether the count is pending or terminated.",
choices=COUNT_STATUSES,
)

@staticmethod
def normalize_status(status_str):
"""Convert a status string into one of COUNT_STATUSES"""
if status_str == 'pending':
return CriminalCount.PENDING
elif status_str == 'terminated':
return CriminalCount.TERMINATED


class CriminalComplaint(models.Model):
"""The criminal complaints associated with a PartyType object (i.e.,
associated with a party in a docket.
"""
party_type = models.ForeignKey(
PartyType,
help_text="The docket and party the complaints are associated with.",
related_name="criminal_complaints",
)
name = models.TextField(
help_text="The name of the criminal complaint, for example, '8:1326 "
"Reentry of Deported Alien'",
)
disposition = models.TextField(
help_text="The disposition of the criminal complaint.",
)


class Party(models.Model):
date_created = models.DateTimeField(
help_text="The time when this item was created",
Expand Down

0 comments on commit 0310b47

Please sign in to comment.