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

3175 courthouses - Add Courthouse Table to search #3184

Merged
merged 8 commits into from
Sep 26, 2023
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
251 changes: 251 additions & 0 deletions cl/search/migrations/0020_courthouse_and_more.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
# Generated by Django 4.2.4 on 2023-09-26 02:01

from django.db import migrations, models
import django.db.models.deletion
import localflavor.us.models
import pgtrigger.compiler
import pgtrigger.migrations


class Migration(migrations.Migration):
dependencies = [
("search", "0019_add_docket_source_noop"),
]

operations = [
migrations.CreateModel(
name="Courthouse",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"court_seat",
models.BooleanField(
default=False,
help_text="Is this the seat of the Court?",
null=True,
),
),
(
"building_name",
models.TextField(
blank=True, help_text="Ex. John Adams Courthouse."
),
),
(
"address1",
models.TextField(
blank=True,
help_text="The normalized address1 of the courthouse.",
),
),
(
"address2",
models.TextField(
blank=True,
help_text="The normalized address2 of the courthouse.",
),
),
(
"city",
models.TextField(
blank=True,
help_text="The normalized city of the courthouse.",
),
),
(
"county",
models.TextField(
blank=True,
help_text="The county, if any, where the courthouse resides.",
),
),
(
"state",
localflavor.us.models.USPostalCodeField(
blank=True,
help_text="The two-letter USPS postal abbreviation for the organization w/ obsolete state options.",
max_length=2,
),
),
(
"zip_code",
localflavor.us.models.USZipCodeField(
blank=True,
help_text="The zip code for the organization, XXXXX or XXXXX-XXXX work.",
max_length=10,
),
),
(
"country_code",
models.TextField(
choices=[
("GB", "United Kingdom"),
("US", "United States"),
],
default="US",
help_text="The two letter country code.",
),
),
],
options={
"verbose_name_plural": "Courthouses",
},
),
pgtrigger.migrations.RemoveTrigger(
model_name="court",
name="update_or_delete_snapshot_delete",
),
pgtrigger.migrations.RemoveTrigger(
model_name="court",
name="update_or_delete_snapshot_update",
),
migrations.AddField(
model_name="court",
name="appeals_to",
field=models.ManyToManyField(
blank=True,
help_text="Appellate courts for this court",
related_name="appeals_from",
to="search.court",
),
),
migrations.AddField(
model_name="court",
name="parent_court",
field=models.ForeignKey(
blank=True,
help_text="Parent court for subdivisions",
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="child_courts",
to="search.court",
),
),
migrations.AddField(
model_name="courtevent",
name="parent_court",
field=models.ForeignKey(
blank=True,
db_constraint=False,
help_text="Parent court for subdivisions",
null=True,
on_delete=django.db.models.deletion.DO_NOTHING,
related_name="+",
related_query_name="+",
to="search.court",
),
),
migrations.AlterField(
model_name="court",
name="jurisdiction",
field=models.CharField(
choices=[
("F", "Federal Appellate"),
("FD", "Federal District"),
("FB", "Federal Bankruptcy"),
("FBP", "Federal Bankruptcy Panel"),
("FS", "Federal Special"),
("S", "State Supreme"),
("SA", "State Appellate"),
("ST", "State Trial"),
("SS", "State Special"),
("TRS", "Tribal Supreme"),
("TRA", "Tribal Appellate"),
("TRT", "Tribal Trial"),
("TRX", "Tribal Special"),
("TS", "Territory Supreme"),
("TA", "Territory Appellate"),
("TT", "Territory Trial"),
("TSP", "Territory Special"),
("SAG", "State Attorney General"),
("MA", "Military Appellate"),
("MT", "Military Trial"),
("C", "Committee"),
("I", "International"),
("T", "Testing"),
],
help_text="the jurisdiction of the court, one of: F (Federal Appellate), FD (Federal District), FB (Federal Bankruptcy), FBP (Federal Bankruptcy Panel), FS (Federal Special), S (State Supreme), SA (State Appellate), ST (State Trial), SS (State Special), TRS (Tribal Supreme), TRA (Tribal Appellate), TRT (Tribal Trial), TRX (Tribal Special), TS (Territory Supreme), TA (Territory Appellate), TT (Territory Trial), TSP (Territory Special), SAG (State Attorney General), MA (Military Appellate), MT (Military Trial), C (Committee), I (International), T (Testing)",
max_length=3,
),
),
migrations.AlterField(
model_name="courtevent",
name="jurisdiction",
field=models.CharField(
choices=[
("F", "Federal Appellate"),
("FD", "Federal District"),
("FB", "Federal Bankruptcy"),
("FBP", "Federal Bankruptcy Panel"),
("FS", "Federal Special"),
("S", "State Supreme"),
("SA", "State Appellate"),
("ST", "State Trial"),
("SS", "State Special"),
("TRS", "Tribal Supreme"),
("TRA", "Tribal Appellate"),
("TRT", "Tribal Trial"),
("TRX", "Tribal Special"),
("TS", "Territory Supreme"),
("TA", "Territory Appellate"),
("TT", "Territory Trial"),
("TSP", "Territory Special"),
("SAG", "State Attorney General"),
("MA", "Military Appellate"),
("MT", "Military Trial"),
("C", "Committee"),
("I", "International"),
("T", "Testing"),
],
help_text="the jurisdiction of the court, one of: F (Federal Appellate), FD (Federal District), FB (Federal Bankruptcy), FBP (Federal Bankruptcy Panel), FS (Federal Special), S (State Supreme), SA (State Appellate), ST (State Trial), SS (State Special), TRS (Tribal Supreme), TRA (Tribal Appellate), TRT (Tribal Trial), TRX (Tribal Special), TS (Territory Supreme), TA (Territory Appellate), TT (Territory Trial), TSP (Territory Special), SAG (State Attorney General), MA (Military Appellate), MT (Military Trial), C (Committee), I (International), T (Testing)",
max_length=3,
),
),
pgtrigger.migrations.AddTrigger(
model_name="court",
trigger=pgtrigger.compiler.Trigger(
name="update_or_delete_snapshot_update",
sql=pgtrigger.compiler.UpsertTriggerSql(
condition='WHEN (OLD."id" IS DISTINCT FROM (NEW."id") OR OLD."parent_court_id" IS DISTINCT FROM (NEW."parent_court_id") OR OLD."pacer_court_id" IS DISTINCT FROM (NEW."pacer_court_id") OR OLD."pacer_has_rss_feed" IS DISTINCT FROM (NEW."pacer_has_rss_feed") OR OLD."pacer_rss_entry_types" IS DISTINCT FROM (NEW."pacer_rss_entry_types") OR OLD."date_last_pacer_contact" IS DISTINCT FROM (NEW."date_last_pacer_contact") OR OLD."fjc_court_id" IS DISTINCT FROM (NEW."fjc_court_id") OR OLD."in_use" IS DISTINCT FROM (NEW."in_use") OR OLD."has_opinion_scraper" IS DISTINCT FROM (NEW."has_opinion_scraper") OR OLD."has_oral_argument_scraper" IS DISTINCT FROM (NEW."has_oral_argument_scraper") OR OLD."position" IS DISTINCT FROM (NEW."position") OR OLD."citation_string" IS DISTINCT FROM (NEW."citation_string") OR OLD."short_name" IS DISTINCT FROM (NEW."short_name") OR OLD."full_name" IS DISTINCT FROM (NEW."full_name") OR OLD."url" IS DISTINCT FROM (NEW."url") OR OLD."start_date" IS DISTINCT FROM (NEW."start_date") OR OLD."end_date" IS DISTINCT FROM (NEW."end_date") OR OLD."jurisdiction" IS DISTINCT FROM (NEW."jurisdiction") OR OLD."notes" IS DISTINCT FROM (NEW."notes"))',
func='INSERT INTO "search_courtevent" ("citation_string", "date_last_pacer_contact", "date_modified", "end_date", "fjc_court_id", "full_name", "has_opinion_scraper", "has_oral_argument_scraper", "id", "in_use", "jurisdiction", "notes", "pacer_court_id", "pacer_has_rss_feed", "pacer_rss_entry_types", "parent_court_id", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "position", "short_name", "start_date", "url") VALUES (OLD."citation_string", OLD."date_last_pacer_contact", OLD."date_modified", OLD."end_date", OLD."fjc_court_id", OLD."full_name", OLD."has_opinion_scraper", OLD."has_oral_argument_scraper", OLD."id", OLD."in_use", OLD."jurisdiction", OLD."notes", OLD."pacer_court_id", OLD."pacer_has_rss_feed", OLD."pacer_rss_entry_types", OLD."parent_court_id", _pgh_attach_context(), NOW(), \'update_or_delete_snapshot\', OLD."id", OLD."position", OLD."short_name", OLD."start_date", OLD."url"); RETURN NULL;',
hash="d886ec89d1364a03c4f04630b4a0e1363d97fcc1",
operation="UPDATE",
pgid="pgtrigger_update_or_delete_snapshot_update_c94ab",
table="search_court",
when="AFTER",
),
),
),
pgtrigger.migrations.AddTrigger(
model_name="court",
trigger=pgtrigger.compiler.Trigger(
name="update_or_delete_snapshot_delete",
sql=pgtrigger.compiler.UpsertTriggerSql(
func='INSERT INTO "search_courtevent" ("citation_string", "date_last_pacer_contact", "date_modified", "end_date", "fjc_court_id", "full_name", "has_opinion_scraper", "has_oral_argument_scraper", "id", "in_use", "jurisdiction", "notes", "pacer_court_id", "pacer_has_rss_feed", "pacer_rss_entry_types", "parent_court_id", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "position", "short_name", "start_date", "url") VALUES (OLD."citation_string", OLD."date_last_pacer_contact", OLD."date_modified", OLD."end_date", OLD."fjc_court_id", OLD."full_name", OLD."has_opinion_scraper", OLD."has_oral_argument_scraper", OLD."id", OLD."in_use", OLD."jurisdiction", OLD."notes", OLD."pacer_court_id", OLD."pacer_has_rss_feed", OLD."pacer_rss_entry_types", OLD."parent_court_id", _pgh_attach_context(), NOW(), \'update_or_delete_snapshot\', OLD."id", OLD."position", OLD."short_name", OLD."start_date", OLD."url"); RETURN NULL;',
hash="d72fa3660f1c1d7de0feadd1ba92c2e70f48da07",
operation="DELETE",
pgid="pgtrigger_update_or_delete_snapshot_delete_84ec4",
table="search_court",
when="AFTER",
),
),
),
migrations.AddField(
model_name="courthouse",
name="court",
field=models.ForeignKey(
help_text="The court object associated with this courthouse.",
on_delete=django.db.models.deletion.CASCADE,
related_name="courts",
to="search.court",
),
),
]
Loading