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

Court class detail views #1803

Merged
merged 4 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
27 changes: 27 additions & 0 deletions peachjam/migrations/0126_courtclass_slug.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 3.2.24 on 2024-04-23 08:26

from django.db import migrations, models
from django.utils.text import slugify


def create_slug(apps, schema_editor):
CourtClass = apps.get_model("peachjam", "CourtClass")
for court_class in CourtClass.objects.all():
court_class.slug = slugify(court_class.name)
court_class.save()


class Migration(migrations.Migration):
dependencies = [
("peachjam", "0125_judgment_auto_assign_title"),
]

operations = [
migrations.AddField(
model_name="courtclass",
name="slug",
field=models.SlugField(default="", max_length=255, verbose_name="slug"),
preserve_default=False,
),
migrations.RunPython(create_slug, migrations.RunPython.noop),
]
18 changes: 18 additions & 0 deletions peachjam/migrations/0127_alter_courtclass_slug.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.24 on 2024-04-23 08:34

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("peachjam", "0126_courtclass_slug"),
]

operations = [
migrations.AlterField(
model_name="courtclass",
name="slug",
field=models.SlugField(max_length=255, unique=True, verbose_name="slug"),
),
]
18 changes: 18 additions & 0 deletions peachjam/migrations/0128_courtclass_show_listing_page.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.24 on 2024-04-23 08:54

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("peachjam", "0127_alter_courtclass_slug"),
]

operations = [
migrations.AddField(
model_name="courtclass",
name="show_listing_page",
field=models.BooleanField(default=False),
),
]
12 changes: 12 additions & 0 deletions peachjam/models/judgment.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ def __str__(self):
class CourtClass(models.Model):
name = models.CharField(_("name"), max_length=100, null=False, unique=True)
description = models.TextField(_("description"), null=True, blank=True)
slug = models.SlugField(_("slug"), max_length=255, null=False, unique=True)
order = models.IntegerField(_("order"), null=True, blank=True)
show_listing_page = models.BooleanField(null=False, default=False)

class Meta:
ordering = (
Expand All @@ -87,6 +89,13 @@ class Meta:
def __str__(self):
return self.name

def get_absolute_url(self):
return reverse("court_class", args=[self.slug])

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


class Court(models.Model):
name = models.CharField(_("name"), max_length=255, null=False, unique=True)
Expand Down Expand Up @@ -128,6 +137,9 @@ class Meta:
def __str__(self):
return self.name

def get_absolute_url(self):
return reverse("court", args=[self.code])


class CourtRegistryManager(models.Manager):
def get_queryset(self):
Expand Down
9 changes: 5 additions & 4 deletions peachjam/static/stylesheets/_global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ main {
flex-grow: 1;
}

.courts__column-wrapper {
// newspaper-like dynamic columns
.flow-columns {
columns: 3 auto;

@include media-breakpoint-down(lg) {
Expand All @@ -28,10 +29,10 @@ main {
@include media-breakpoint-down(sm) {
columns: 1;
}
}

.courts__item {
break-inside: avoid;
.flow-columns-group {
break-inside: avoid;
}
}

mark {
Expand Down
11 changes: 11 additions & 0 deletions peachjam/templates/peachjam/_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 "court_class_month" court_class.slug year m|date:'n' %}">{{ m|date:"F" }}</a>
{% endblock %}
{% block month_option %}
<option value="{% url "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/_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 "court_class_year" court_class.slug y.year %}">{{ y.year }}</a>
{% endblock %}
{% block year_option %}
<option value="{% url "court_class_year" court_class.slug 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
@@ -1,8 +1,8 @@
{% load peachjam i18n %}
{% if court_classes %}
<div class="courts__column-wrapper mb-3">
<div class="flow-columns mb-3">
{% for court_class in court_classes %}
<div class="courts__item mb-3">
<div class="flow-columns-group mb-4">
<h4 class="mb-2">{{ court_class }}</h4>
{% if court_class.courts.all %}
<ul class="list-unstyled">
Expand All @@ -12,6 +12,10 @@ <h4 class="mb-2">{{ court_class }}</h4>
</li>
{% endfor %}
</ul>
{% if court_class.show_listing_page %}
<a class="btn btn-sm btn-primary"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend we make this a simple link below the h4 heading, with class="mb-3" and text "All judgments"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea. this is how it looks now
image

href="{% url 'court_class' court_class.slug %}">{% trans 'View all' %}</a>
{% endif %}
{% else %}
<div>{% trans 'No courts found.' %}</div>
{% endif %}
Expand Down
38 changes: 38 additions & 0 deletions peachjam/templates/peachjam/_court_months_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{% load i18n %}
{% if months and years %}
<div id="monthFilter"
class="pl-0 mt-2 mb-3 align-items-center d-none d-lg-flex">
<i class="bi bi-calendar me-2"></i>
<div>
<a class="{% if not month %} active{% endif %}"
href="{{ all_months_url }}">{% trans 'All months' %}</a>
</div>
<ul class="year-nav mb-0 ms-2">
{% for m in months %}
<li>
{% if m|date:"F" == month %}
{{ m|date:"F" }}
{% else %}
{% block month_link %}
<a href="{% url "court_month" court.code year m|date:'n' %}">{{ m|date:"F" }}</a>
{% endblock %}
{% endif %}
</li>
{% endfor %}
</ul>
</div>
<select class="form-select mb-3 d-block d-lg-none"
data-component="NavigationSelect">
<option value="{{ all_months_url }}">
{% trans 'All months' %}
</option>
{% for m in months %}
{% block month_option %}
<option value="{% url "court_month" court.code year m|date:'n' %}"
{% if m|date:"F" == month %} selected{% endif %}>
{{ m|date:"F" }}
</option>
{% endblock %}
{% endfor %}
</select>
{% endif %}
11 changes: 11 additions & 0 deletions peachjam/templates/peachjam/_court_registries_months_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 "court_registry_month" court.code registry.code year m|date:'n' %}">{{ m|date:"F" }}</a>
{% endblock %}
{% block month_option %}
<option value="{% url "court_registry_month" court.code registry.code 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/_court_registries_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 "court_registry_year" court.code registry.code y.year %}">{{ y.year }}</a>
{% endblock %}
{% block year_option %}
<option value="{% url "court_registry_year" court.code registry.code y.year %}"
{% if y.year == year %} selected{% endif %}>
{{ y.year }}
</option>
{% endblock %}
37 changes: 37 additions & 0 deletions peachjam/templates/peachjam/_court_years_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{% load i18n %}
{% if years %}
<div class="pl-0 mt-2 mb-3 align-items-center d-none d-lg-flex">
<i class="bi bi-calendar me-2"></i>
<div>
<a class="{% if not year %} active{% endif %}"
href="{{ all_years_url }}">{% trans 'All years' %}</a>
</div>
<ul class="year-nav mb-0 ms-2">
{% for y in years %}
<li>
{% if y.year == year %}
{{ y.year }}
{% else %}
{% block year_link %}
<a href="{% url "court_year" court.code y.year %}">{{ y.year }}</a>
{% endblock %}
{% endif %}
</li>
{% endfor %}
</ul>
</div>
<select class="form-select mb-3 d-block d-lg-none"
data-component="NavigationSelect">
<option value="{{ all_years_url }}">
{% trans 'All years' %}
</option>
{% for y in years %}
{% block year_option %}
<option value="{% url "court_year" court.code y.year %}"
{% if y.year == year %} selected{% endif %}>
{{ y.year }}
</option>
{% endblock %}
{% endfor %}
</select>
{% endif %}
6 changes: 3 additions & 3 deletions peachjam/templates/peachjam/_registries.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{% load i18n %}
{% if registries %}
<h4>{{ registry_label_plural }}</h4>
<div class="row mb-4">
<div class="flow-columns mb-4">
{% for group in registry_groups %}
<div class="col-sm">
<div class="flow-columns-group mb-4">
<ul class="list-unstyled">
{% for r in group %}
{% if r.code == registry.code %}
<li>{{ r.name }}</li>
{% else %}
<li class="inactive">
<li>
<a href="{{ r.get_absolute_url }}">{{ r.name }}</a>
</li>
{% endif %}
Expand Down
8 changes: 8 additions & 0 deletions peachjam/templates/peachjam/court_class_detail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% extends 'peachjam/court_detail.html' %}
{% load i18n %}
{% block year_list %}
{% include "peachjam/_court_class_years_list.html" %}
{% endblock %}
{% block month_list %}
{% include "peachjam/_court_class_month_list.html" %}
{% endblock %}
40 changes: 30 additions & 10 deletions peachjam/templates/peachjam/court_detail.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
{% extends 'peachjam/layouts/document_list.html' %}
{% load i18n %}
{% block title %}{{ formatted_court_name }}{% endblock %}
{% block title %}{{ page_title }}{% endblock %}
{% block breadcrumbs %}
<div class="container">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="{% url 'judgment_list' %}">{% trans 'Judgments' %}</a>
</li>
<li class="breadcrumb-item">
<a href="{% url 'court' court.code %}">{{ court.name }}</a>
</li>
{% if court.court_class.show_listing_page %}
<li class="breadcrumb-item">
<a href="{% url '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 'court_class' court_class.slug %}">{{ court_class.name }}</a>
</li>
{% endif %}
{% if court %}
<li class="breadcrumb-item">
<a href="{% url 'court' court.code %}">{{ court.name }}</a>
</li>
{% endif %}
{% if registry %}
<li class="breadcrumb-item">
<a href="{% url 'court_registry' court.code registry.code %}">{{ registry.name }}</a>
</li>
{% endif %}
</ol>
</nav>
</div>
Expand All @@ -23,13 +39,17 @@
{% endwith %}
{% endblock %}
{% block page-header %}
<h1 class="mt-4">{{ formatted_court_name }}</h1>
<h1 class="mt-4">{{ page_title }}</h1>
{% include 'peachjam/_document_count.html' %}
{% include 'peachjam/_registries.html' %}
{% include 'peachjam/_years_list.html' %}
{% if months %}
{% include 'peachjam/_months_list.html' %}
{% endif %}
{% block court_list %}
{% include 'peachjam/_registries.html' %}
{% endblock %}
{% block year_list %}
{% include 'peachjam/_court_years_list.html' %}
{% endblock %}
{% block month_list %}
{% include 'peachjam/_court_months_list.html' %}
{% endblock %}
{% endblock %}
{% block content %}
{% if grouped_documents %}
Expand Down
20 changes: 5 additions & 15 deletions peachjam/templates/peachjam/court_registry_detail.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
{% extends 'peachjam/court_detail.html' %}
{% load i18n %}
{% block title %}{{ formatted_court_name }}{% endblock %}
{% block breadcrumbs %}
<div class="container">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="{% url 'judgment_list' %}">{% trans 'Judgments' %}</a>
</li>
<li class="breadcrumb-item">
<a href="{% url 'court' court.code %}">{{ court.name }}</a>
</li>
<li class="breadcrumb-item active">{{ registry.name }}</li>
</ol>
</nav>
</div>
{% block year_list %}
{% include "peachjam/_court_registries_years_list.html" %}
{% endblock %}
{% block month_list %}
{% include "peachjam/_court_registries_months_list.html" %}
{% endblock %}
Loading
Loading