Skip to content

Commit

Permalink
adds lower bench model
Browse files Browse the repository at this point in the history
  • Loading branch information
actlikewill committed Mar 4, 2024
1 parent f65531d commit edc851c
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 23 deletions.
9 changes: 9 additions & 0 deletions peachjam/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
LegalInstrument,
Legislation,
Locality,
LowerBench,
MatterType,
OrderOutcome,
PeachJamSettings,
Expand Down Expand Up @@ -700,6 +701,13 @@ class BenchInline(admin.TabularInline):
verbose_name_plural = gettext_lazy("judges")


class LowerBenchInline(admin.TabularInline):
model = LowerBench
extra = 3
verbose_name = gettext_lazy("lower court judge")
verbose_name_plural = gettext_lazy("lower court judges")


class JudgmentRelationshipStackedInline(NonrelatedTabularInline):
model = Relationship
fields = ["predicate", "subject_work"]
Expand Down Expand Up @@ -748,6 +756,7 @@ class JudgmentAdmin(ImportExportMixin, DocumentAdmin):
resource_class = JudgmentResource
inlines = [
BenchInline,
LowerBenchInline,
CaseNumberAdmin,
JudgmentRelationshipStackedInline,
] + DocumentAdmin.inlines
Expand Down
23 changes: 0 additions & 23 deletions peachjam/migrations/0120_judgment_lower_court_judges.py

This file was deleted.

60 changes: 60 additions & 0 deletions peachjam/migrations/0120_lower_court_judges.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Generated by Django 3.2.21 on 2024-03-04 09:26

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("peachjam", "0119_matomo"),
]

operations = [
migrations.CreateModel(
name="LowerBench",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"judge",
models.ForeignKey(
on_delete=django.db.models.deletion.PROTECT,
to="peachjam.judge",
verbose_name="lower_court_judge",
),
),
(
"judgment",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="lower_bench",
to="peachjam.judgment",
verbose_name="judgment",
),
),
],
options={
"ordering": ("pk",),
"unique_together": {("judgment", "judge")},
},
),
migrations.AddField(
model_name="judgment",
name="lower_court_judges",
field=models.ManyToManyField(
blank=True,
related_name="lower_court_judgments",
through="peachjam.LowerBench",
to="peachjam.Judge",
verbose_name="lower court judges",
),
),
]
17 changes: 17 additions & 0 deletions peachjam/models/judgment.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,22 @@ class Meta:
unique_together = ("judgment", "judge")


class LowerBench(models.Model):
judgment = models.ForeignKey(
"Judgment",
related_name="lower_bench",
on_delete=models.CASCADE,
verbose_name=_("judgment"),
)
judge = models.ForeignKey(
Judge, on_delete=models.PROTECT, verbose_name=_("lower_court_judge")
)

class Meta:
ordering = ("pk",)
unique_together = ("judgment", "judge")


class Judgment(CoreDocument):
court = models.ForeignKey(
Court, on_delete=models.PROTECT, null=True, verbose_name=_("court")
Expand All @@ -201,6 +217,7 @@ class Judgment(CoreDocument):
)
lower_court_judges = models.ManyToManyField(
Judge,
through=LowerBench,
blank=True,
verbose_name=_("lower court judges"),
related_name="lower_court_judgments",
Expand Down

0 comments on commit edc851c

Please sign in to comment.