Skip to content

Commit

Permalink
fetches case history in judgment detail view
Browse files Browse the repository at this point in the history
  • Loading branch information
actlikewill committed May 31, 2024
1 parent 3d66559 commit b2b2ff1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion peachjam/models/judgment.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ class CaseHistory(models.Model):
date = models.DateField(_("date"), null=True, blank=True)

class Meta:
ordering = ["date"]
ordering = ["-date"]
verbose_name = _("case history")
verbose_name_plural = _("case histories")

Expand Down
10 changes: 5 additions & 5 deletions peachjam/templates/peachjam/_case_histories.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
<table class="table table-striped">
<thead>
<tr>
<th>{% trans 'Date' %}</th>
<th>{% trans 'Case' %}</th>
<th>{% trans 'Outcome' %}</th>
<th>{% trans 'Court' %}</th>
<th>{% trans 'Judges' %}</th>
<th>{% trans 'Date' %}</th>
<th>{% trans 'Outcome' %}</th>
</tr>
</thead>
<tbody>
{% for history in document.case_histories.all %}
{% for history in case_histories %}
<tr>
<td>{{ history.date }}</td>
<td>
{% if history.historical_judgment %}
<a target="_blank"
Expand All @@ -20,15 +21,14 @@
{{ history.case_number }}
{% endif %}
</td>
<td>{{ history.outcome }}</td>
<td>{{ history.court }}</td>
<td>
{% for judge in history.judges.all %}
{{ judge }}
{% if not forloop.last %},{% endif %}
{% endfor %}
</td>
<td>{{ history.date }}</td>
<td>{{ history.outcome }}</td>
</tr>
{% endfor %}
</tbody>
Expand Down
4 changes: 2 additions & 2 deletions peachjam/templates/peachjam/layouts/document_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ <h1>{{ document.title }}</h1>
</button>
</li>
{% endif %}
{% if document.case_histories.all|length %}
{% if case_histories %}
<li class="nav-item" role="presentation">
<button class="nav-link"
data-bs-toggle="tab"
Expand Down Expand Up @@ -435,7 +435,7 @@ <h5>
<div class="container">{% include 'peachjam/_citations.html' %}</div>
</div>
{% endif %}
{% if document.case_histories.all|length %}
{% if case_histories %}
<div class="tab-pane fade"
id="case-history-tab"
role="tabpanel"
Expand Down
5 changes: 4 additions & 1 deletion peachjam/views/judgment.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ def get_context_data(self, **kwargs):
{
"judges": self.get_object()
.bench.prefetch_related("judge")
.values_list("judge__name", flat=True)
.values_list("judge__name", flat=True),
"case_histories": self.get_object()
.case_histories.select_related("court", "historical_judgment")
.prefetch_related("judges"),
}
)
return context

0 comments on commit b2b2ff1

Please sign in to comment.