forked from sc3/cook-convictions-data
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update loading of final statute and IUCR fields
Add final_statute_formatted field to the Disposition and Conviction model. Add a format_statute() function to format the parsed statute that will go into final_statute_formatted. Factor final_statute field population out into a method, load_final_statute. Remove trailing whitespace from files edited in this commit. Rename statute2iucr management command to load_final_statute_and_iucr to reflect these changes. Fix statute.strip_surrounding_parens to handle empty string Addresses sc3#7, sc3/cook-convictions#83
- Loading branch information
Showing
7 changed files
with
396 additions
and
124 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
convictions_data/management/commands/load_final_statute_and_iucr.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import logging | ||
|
||
from django.core.management.base import BaseCommand | ||
from django.db import transaction | ||
|
||
from convictions_data.models import Disposition | ||
from convictions_data.statute import (get_iucr, IUCRLookupError, | ||
ILCSLookupError, StatuteFormatError) | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
class Command(BaseCommand): | ||
help = ("Load the final statute, nicely formatted statute and IUCR code " | ||
"from the statute or ammended statute fields") | ||
|
||
def handle(self, *args, **options): | ||
with transaction.atomic(): | ||
for disposition in Disposition.objects.all(): | ||
if disposition.ammndchargstatute: | ||
disposition.load_final_statute_and_iucr(disposition.ammndchargstatute) | ||
disposition.save() | ||
elif disposition.statute: | ||
disposition.load_final_statute_and_iucr(disposition.statute) | ||
disposition.save() |
This file was deleted.
Oops, something went wrong.
235 changes: 235 additions & 0 deletions
235
...migrations/0023_auto__add_field_conviction_final_statute_formatted__add_field_disposit.py
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.