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

Legislation improvements #1821

Merged
merged 10 commits into from
May 27, 2024
26 changes: 19 additions & 7 deletions liiweb/templates/liiweb/legislation_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,31 @@ <h1 class="my-4">{% trans 'Legislation' %}</h1>
<li class="nav-item">
<a class="nav-link {% if view.variant == 'current' %}active{% endif %}"
href="{% url 'legislation_list' %}">
{% trans 'Current legislation' %}
{% block current_tab_title %}
{% trans 'Current legislation' %}
{% endblock %}
</a>
</li>
<li class="nav-item">
<a class="nav-link {% if view.variant == 'repealed' %}active{% endif %}"
href="{% url 'legislation_list_repealed' %}">
{% trans 'Repealed legislation' %}
<a class="nav-link {% if view.variant == 'subleg' %}active{% endif %}"
href="{% url 'legislation_list_subsidiary' %}">
{% block sublegislation_tab_title %}{{ PEACHJAM_SETTINGS.subleg_label }}{% endblock %}
</a>
</li>
<li class="nav-item">
<a class="nav-link {% if view.variant == 'subleg' %}active{% endif %}"
href="{% url 'legislation_list_subsidiary' %}">
{{ PEACHJAM_SETTINGS.subleg_label }}
<a class="nav-link {% if view.variant == 'uncommenced' %}active{% endif %}"
href="{% url 'legislation_list_uncommenced' %}">
{% block uncommenced_tab_title %}
{% trans 'Uncommenced legislation' %}
{% endblock %}
</a>
</li>
<li class="nav-item">
<a class="nav-link {% if view.variant == 'repealed' %}active{% endif %}"
href="{% url 'legislation_list_repealed' %}">
{% block repealed_tab_title %}
{% trans 'Repealed legislation' %}
{% endblock %}
</a>
</li>
<li class="nav-item">
Expand Down
5 changes: 5 additions & 0 deletions liiweb/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
views.LegislationListView.as_view(variant="subleg"),
name="legislation_list_subsidiary",
),
path(
"legislation/uncommenced",
views.LegislationListView.as_view(variant="uncommenced"),
name="legislation_list_uncommenced",
),
# This redirects old Ulii case laws to work with peachjam urls
re_path(
r"^(?P<country>[a-z]{2})/judgment/(?P<court>[-\w]+)/(?P<year>\d+)/(?P<number>\d+)$",
Expand Down
2 changes: 2 additions & 0 deletions liiweb/views/legislation.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def filter_queryset(self, qs):
qs = qs.exclude(parent_work=None).filter(
repealed=False, metadata_json__principal=True
)
elif self.variant == "uncommenced":
qs = qs.filter(metadata_json__commenced=False)
return qs

def get_context_data(self, **kwargs):
Expand Down
16 changes: 15 additions & 1 deletion peachjam/js/components/LegislationTable/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@
<div v-if="false">
{{ $t('Years') }}
{{ $t('Taxonomies') }}
{{ $t('Alphabetical') }}
</div>
</div>
</template>
Expand Down Expand Up @@ -310,8 +311,18 @@ export default {
taxonomyOptions.sort((a, b) => a.value.localeCompare(b.value));
// Sort descending
yearsOptions.sort((a, b) => b.value - a.value);

const alphabet = 'abcdefghijklmnopqrstuvwxyz'.split('').map(letter => ({
label: letter.toUpperCase(),
value: letter
}));
this.facets = [
{
title: this.$t('Alphabetical'),
name: 'alphabetical',
type: 'letter-radio',
value: [],
options: alphabet
},
{
title: this.$t('Years'),
name: 'year',
Expand Down Expand Up @@ -367,6 +378,9 @@ export default {
});
Object.keys(facetDict).forEach((key) => {
data = data.filter((item) => {
if (key === 'alphabetical') {
return item.title.toLowerCase().startsWith(facetDict[key]);
}
if (Array.isArray(facetDict[key])) {
const arr1 = facetDict[key].map((x) => String(x));
const arr2 = item[key].map((x) => String(x));
Expand Down
32 changes: 25 additions & 7 deletions peachjam/models/generic_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,22 +103,40 @@ def search_penalty(self):
return 10.0
return super().search_penalty()

@property
def commenced(self):
return self.metadata_json.get("commenced", None)

def apply_labels(self):
labels = list(self.labels.all())

# label to indicate that this legislation is repealed
label, _ = Label.objects.get_or_create(
repealed_label, _ = Label.objects.get_or_create(
code="repealed",
defaults={"name": "Repealed", "code": "repealed", "level": "danger"},
)

labels = list(self.labels.all())
uncommenced_label, _ = Label.objects.get_or_create(
code="uncommenced",
defaults={
"name": "Uncommenced",
"level": "danger",
},
)

# apply label if repealed
if self.repealed:
if label not in labels:
self.labels.add(label.pk)
elif label in labels:
if repealed_label not in labels:
self.labels.add(repealed_label.pk)
elif repealed_label in labels:
# not repealed, remove label
self.labels.remove(label.pk)
self.labels.remove(repealed_label.pk)

# apply label if not commenced
if not self.commenced:
if uncommenced_label not in labels:
self.labels.add(uncommenced_label.pk)
elif uncommenced_label in labels:
self.labels.remove(uncommenced_label.pk)

super().apply_labels()

Expand Down
2 changes: 1 addition & 1 deletion peachjam/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
"SEARCH_JURISDICTION_FILTER": False,
"MULTIPLE_JURISDICTIONS": False,
"MULTIPLE_LOCALITIES": False,
"PDFJS_TO_TEXT": "bin/pdfjs-to-text",
"PDFJS_TO_TEXT": "bin/pdfjs-to-text" if DEBUG else "pdfjs-to-text",
}

PEACHJAM["ES_INDEX"] = os.environ.get("ES_INDEX", slugify(PEACHJAM["APP_NAME"]))
Expand Down
24 changes: 24 additions & 0 deletions peachjam/templates/peachjam/judgment_detail.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
{% extends 'peachjam/layouts/document_detail.html' %}
{% load i18n %}
{% block breadcrumbs %}
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="{% url 'judgment_list' %}">{% trans 'Judgments' %}</a>
</li>
{% if document.court.court_class.show_listing_page %}
<li class="breadcrumb-item">
<a href="{% url 'court_class' document.court.court_class.slug %}">{{ document.court.court_class.name }}</a>
</li>
{% endif %}
{% if document.court %}
<li class="breadcrumb-item">
<a href="{% url 'court' document.court.code %}">{{ document.court.name }}</a>
</li>
{% endif %}
{% if document.registry %}
<li class="breadcrumb-item">
<a href="{% url 'court_registry' document.court.code document.registry.code %}">{{ document.registry.name }}</a>
</li>
{% endif %}
</ol>
</nav>
{% endblock %}
{% block document-metadata-content-citation %}
{{ block.super }}
{% if document.mnc %}
Expand Down
1 change: 1 addition & 0 deletions peachjam/templates/peachjam/layouts/document_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<div class="d-md-flex justify-content-md-between py-4">
<div>
<h1>{{ document.title }}</h1>
{% block sub-title %}{% endblock %}
{% include 'peachjam/_labels.html' %}
</div>
<div class="d-flex align-items-center">
Expand Down
1 change: 1 addition & 0 deletions peachjam/templates/peachjam/legislation_detail.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% extends 'peachjam/layouts/document_detail.html' %}
{% load i18n peachjam %}
{% block sub-title %}<h2 class="h5 text-muted">{{ document.citation }}</h2>{% endblock %}
{% block document-tabs %}
{{ block.super }}
{% if child_documents %}
Expand Down
Loading