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

Cause lists #2099

Merged
merged 14 commits into from
Oct 17, 2024
10 changes: 10 additions & 0 deletions peachjam/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@
Book,
CaseHistory,
CaseNumber,
CauseList,
CitationLink,
CitationProcessing,
CoreDocument,
Court,
CourtClass,
CourtDivision,
CourtRegistry,
DocumentNature,
DocumentTopic,
Expand Down Expand Up @@ -1014,6 +1016,13 @@ def upload_view(self, request):
return render(request, "admin/judgment_upload_form.html", context)


@admin.register(CauseList)
class CauseListAdmin(DocumentAdmin):
fieldsets = copy.deepcopy(DocumentAdmin.fieldsets)
fieldsets[0][1]["fields"].insert(3, "court")
fieldsets[0][1]["fields"].insert(3, "judges")


@admin.register(Predicate)
class PredicateAdmin(admin.ModelAdmin):
list_display = ("name",)
Expand Down Expand Up @@ -1362,6 +1371,7 @@ class AttorneyAdmin(ImportExportMixin, admin.ModelAdmin):
[
CitationLink,
CourtClass,
CourtDivision,
AttachedFileNature,
CitationProcessing,
Folder,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# Generated by Django 4.2.16 on 2024-10-16 15:08

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


class Migration(migrations.Migration):

dependencies = [
("peachjam", "0167_peachjamsettings_allow_social_logins"),
]

operations = [
migrations.CreateModel(
name="CourtDivision",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"name",
models.CharField(max_length=255, unique=True, verbose_name="name"),
),
(
"code",
models.SlugField(max_length=255, unique=True, verbose_name="code"),
),
(
"order",
models.IntegerField(blank=True, null=True, verbose_name="order"),
),
],
),
migrations.AlterField(
model_name="coredocument",
name="doc_type",
field=models.CharField(
choices=[
("core_document", "Core Document"),
("gazette", "Gazette"),
("generic_document", "Generic Document"),
("judgment", "Judgment"),
("legal_instrument", "Legal Instrument"),
("legislation", "Legislation"),
("book", "Book"),
("journal", "Journal"),
("causelist", "Cause List"),
],
default="core_document",
max_length=255,
verbose_name="document type",
),
),
migrations.CreateModel(
name="CauseList",
fields=[
(
"coredocument_ptr",
models.OneToOneField(
auto_created=True,
on_delete=django.db.models.deletion.CASCADE,
parent_link=True,
primary_key=True,
serialize=False,
to="peachjam.coredocument",
),
),
(
"court",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="causelists",
to="peachjam.court",
verbose_name="court",
),
),
(
"division",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="causelists",
to="peachjam.courtdivision",
),
),
(
"judges",
models.ManyToManyField(
blank=True, to="peachjam.judge", verbose_name="judges"
),
),
(
"registry",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="causelists",
to="peachjam.courtregistry",
),
),
],
options={
"abstract": False,
"base_manager_name": "objects",
},
bases=("peachjam.coredocument",),
),
]
1 change: 1 addition & 0 deletions peachjam/models/core_document_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ class CoreDocument(PolymorphicModel):
("legislation", "Legislation"),
("book", "Book"),
("journal", "Journal"),
("causelist", "Cause List"),
)

# The name of the default nature to use for this type of document, if one is not set. This allows us to ensure
Expand Down
59 changes: 59 additions & 0 deletions peachjam/models/judgment.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,23 @@ def save(self, *args, **kwargs):
return super().save(*args, **kwargs)


class CourtDivision(models.Model):
name = models.CharField(_("name"), max_length=255, null=False, unique=True)
code = models.SlugField(_("code"), max_length=255, null=False, unique=True)
entity_profile = GenericRelation(
"peachjam.EntityProfile", verbose_name=_("profile")
)
order = models.IntegerField(_("order"), null=True, blank=True)

def __str__(self):
return self.name

def save(self, *args, **kwargs):
if not self.code:
self.code = slugify(self.name)
return super().save(*args, **kwargs)


class Court(models.Model):
name = models.CharField(_("name"), max_length=255, null=False, unique=True)
code = models.SlugField(_("code"), max_length=255, null=False, unique=True)
Expand Down Expand Up @@ -539,3 +556,45 @@ def __str__(self):
elif self.case_number:
return f"{self.case_number}"
return _("Case history")


class CauseList(CoreDocument):
frbr_uri_doctypes = ["doc"]
default_nature = ("causelist", "Cause list")
court = models.ForeignKey(
Court,
on_delete=models.PROTECT,
null=True,
verbose_name=_("court"),
related_name="causelists",
)
registry = models.ForeignKey(
CourtRegistry,
on_delete=models.PROTECT,
null=True,
related_name="causelists",
blank=True,
)
division = models.ForeignKey(
CourtDivision,
on_delete=models.PROTECT,
null=True,
related_name="causelists",
blank=True,
)
judges = models.ManyToManyField(Judge, blank=True, verbose_name=_("judges"))

def assign_title(self):
court_name = self.registry.name if self.registry else ""
if not self.registry:
court_name = self.court.name if self.court else ""
nature_name = self.nature.name if self.nature else ""
date_str = self.date.strftime("%d %B %Y")

self.title = f"{court_name} - {nature_name} - {date_str}"

def pre_save(self):
self.assign_title()
self.frbr_uri_doctype = "doc"
self.doc_type = "causelist"
longhotsummer marked this conversation as resolved.
Show resolved Hide resolved
super().pre_save()
11 changes: 11 additions & 0 deletions peachjam/templates/peachjam/_causelist_court_class_month_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% extends "peachjam/_court_months_list.html" %}
{% load i18n %}
{% block month_link %}
<a href="{% url "causelist_court_class_month" court_class.slug year m|date:'n' %}">{{ m|date:"F" }}</a>
{% endblock %}
{% block month_option %}
<option value="{% url "causelist_court_class_month" court_class.slug year m|date:'n' %}"
{% if m|date:"F" == month %} selected{% endif %}>
{{ m|date:"F" }}
</option>
{% endblock %}
11 changes: 11 additions & 0 deletions peachjam/templates/peachjam/_causelist_court_class_years_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% extends "peachjam/_court_years_list.html" %}
{% load i18n %}
{% block year_link %}
<a href="{% url "causelist_court_class_year" court_class.slug y.year %}">{{ y.year }}</a>
{% endblock %}
{% block year_option %}
<option value="{% url "causelist_court_class_year" court_class.slug y.year %}"
{% if y.year == year %} selected{% endif %}>
{{ y.year }}
</option>
{% endblock %}
8 changes: 8 additions & 0 deletions peachjam/templates/peachjam/_causelist_court_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% extends "peachjam/_court_list.html" %}
{% load i18n %}
{% block court_class_link %}
<a href="{% url 'causelist_court_class' court_class.slug %}">{% trans 'All causelists' %}</a>
{% endblock %}
{% block court_link %}
<a href="{% url 'causelist_court' court.code %}">{{ court.name }}</a>
{% endblock %}
10 changes: 10 additions & 0 deletions peachjam/templates/peachjam/_causelist_court_months_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{% extends "peachjam/_court_months_list.html" %}
{% load i18n %}
{% block month_link %}
<a href="{% url "causelist_court_month" court.code year m|date:'n' %}">{{ m|date:"F" }}</a>
{% endblock %}
{% block month_option %}
<option value="{% url "causelist_court_month" court.code year m|date:'n' %}"
{% if m|date:"F" == month %} selected{% endif %}>
</option>
{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% extends "peachjam/_court_months_list.html" %}
{% load i18n %}
{% block month_link %}
<a href="{% url "causelist_court_registry_month" court.code registry.code year m|date:'n' %}">{{ m|date:"F" }}</a>
{% endblock %}
{% block month_option %}
<option value="{% url "causelist_court_registry_month" court.code registry.code year m|date:'n' %}"
{% if m|date:"F" == month %} selected{% endif %}>
{{ m|date:"F" }}
</option>
{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% extends "peachjam/_court_years_list.html" %}
{% load i18n %}
{% block year_link %}
<a href="{% url "causelist_court_registry_year" court.code registry.code y.year %}">{{ y.year }}</a>
{% endblock %}
{% block year_option %}
<option value="{% url "causelist_court_registry_year" court.code registry.code y.year %}"
{% if y.year == year %} selected{% endif %}>
{{ y.year }}
</option>
{% endblock %}
11 changes: 11 additions & 0 deletions peachjam/templates/peachjam/_causelist_court_years_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% extends "peachjam/_court_years_list.html" %}
{% load i18n %}
{% block year_link %}
<a href="{% url "causelist_court_year" court.code y.year %}">{{ y.year }}</a>
{% endblock %}
{% block year_option %}
<option value="{% url "causelist_court_year" court.code y.year %}"
{% if y.year == year %} selected{% endif %}>
{{ y.year }}
</option>
{% endblock %}
8 changes: 6 additions & 2 deletions peachjam/templates/peachjam/_court_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@
<h4 class="mb-2">{{ court_class }}</h4>
{% if court_class.show_listing_page %}
<div class="mb-3">
<a href="{% url 'court_class' court_class.slug %}">{% trans 'All judgments' %}</a>
{% block court_class_link %}
<a href="{% url 'court_class' court_class.slug %}">{% trans 'All judgments' %}</a>
{% endblock %}
</div>
{% endif %}
{% if court_class.courts.all %}
<ul class="list-unstyled">
{% for court in court_class.courts.all %}
<li>
<a href="{% url 'court' court.code %}">{{ court.name }}</a>
{% block court_link %}
<a href="{% url 'court' court.code %}">{{ court.name }}</a>
{% endblock %}
</li>
{% endfor %}
</ul>
Expand Down
8 changes: 8 additions & 0 deletions peachjam/templates/peachjam/causelist_court_class_detail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% extends 'peachjam/causelist_court_detail.html' %}
{% load i18n %}
{% block year_list %}
{% include "peachjam/_causelist_court_class_years_list.html" %}
{% endblock %}
{% block month_list %}
{% include "peachjam/_causelist_court_class_month_list.html" %}
{% endblock %}
46 changes: 46 additions & 0 deletions peachjam/templates/peachjam/causelist_court_detail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{% extends 'peachjam/layouts/document_list.html' %}
{% load i18n %}
{% block title %}{{ page_title }}{% endblock %}
{% block breadcrumbs %}
<div class="container">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="{% url 'home_page' %}">{% trans 'Home' %}</a>
</li>
<li class="breadcrumb-item">
<a href="{% url 'causelist_list' %}">{% trans 'Cause Lists' %}</a>
</li>
{% if court.court_class.show_listing_page %}
<li class="breadcrumb-item">
<a href="{% url 'causelist_court_class' court.court_class.slug %}">{{ court.court_class.name }}</a>
</li>
{% elif court_class.show_listing_page %}
<li class="breadcrumb-item">
<a href="{% url 'causelist_court_class' court_class.slug %}">{{ court_class.name }}</a>
</li>
{% endif %}
{% if court %}
<li class="breadcrumb-item">
<a href="{% url 'causelist_court' court.code %}">{{ court.name }}</a>
</li>
{% endif %}
</ol>
</nav>
</div>
{% endblock %}
{% block page-title %}
{% if not entity_profile %}<h1 class="mt-4">{{ page_title }}</h1>{% endif %}
{% endblock %}
{% block page-header %}
{{ block.super }}
{% block court_list %}
{% include 'peachjam/_registries.html' %}
{% endblock %}
{% block year_list %}
{% include 'peachjam/_causelist_court_years_list.html' %}
{% endblock %}
{% block month_list %}
{% include 'peachjam/_causelist_court_months_list.html' %}
{% endblock %}
{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% extends 'peachjam/causelist_court_detail.html' %}
{% load i18n %}
{% block year_list %}
{% include "peachjam/_causelist_court_registries_years_list.html" %}
{% endblock %}
{% block month_list %}
{% include "peachjam/_causelist_court_registries_months_list.html" %}
{% endblock %}
Loading
Loading