diff --git a/africanlii/templates/africanlii/au_institution_detail.html b/africanlii/templates/africanlii/au_institution_detail.html index 35bbae2c1..9f6341d89 100644 --- a/africanlii/templates/africanlii/au_institution_detail.html +++ b/africanlii/templates/africanlii/au_institution_detail.html @@ -24,7 +24,7 @@ {% block entity-profile %} {% with entity_profile=author.au_institution.entity_profile.first entity_profile_title=author.name %} {% if entity_profile %} -
{% include 'peachjam/_entity_profile.html' %}
+ {% include 'peachjam/_entity_profile.html' %} {% endif %} {% endwith %} {% endblock %} diff --git a/africanlii/templates/africanlii/au_organ_detail.html b/africanlii/templates/africanlii/au_organ_detail.html index 1cfc4248a..3e99f6f91 100644 --- a/africanlii/templates/africanlii/au_organ_detail.html +++ b/africanlii/templates/africanlii/au_organ_detail.html @@ -23,7 +23,7 @@ {% block entity-profile %} {% with entity_profile=author.au_organ.entity_profile.first entity_profile_title=author.name %} {% if entity_profile %} -
{% include 'peachjam/_entity_profile.html' %}
+ {% include 'peachjam/_entity_profile.html' %} {% endif %} {% endwith %} {% endblock %} diff --git a/africanlii/templates/africanlii/member_state_detail.html b/africanlii/templates/africanlii/member_state_detail.html index aeaef1ccd..4458dfff1 100644 --- a/africanlii/templates/africanlii/member_state_detail.html +++ b/africanlii/templates/africanlii/member_state_detail.html @@ -24,7 +24,7 @@ {% block entity-profile %} {% with entity_profile=member_state.entity_profile.first entity_profile_title=member_state.name %} {% if entity_profile %} -
{% include 'peachjam/_entity_profile.html' %}
+ {% include 'peachjam/_entity_profile.html' %} {% endif %} {% endwith %} {% endblock %} diff --git a/africanlii/templates/africanlii/regional_economic_community_detail.html b/africanlii/templates/africanlii/regional_economic_community_detail.html index dc9da8b18..7b93d26d6 100644 --- a/africanlii/templates/africanlii/regional_economic_community_detail.html +++ b/africanlii/templates/africanlii/regional_economic_community_detail.html @@ -24,7 +24,7 @@ {% block entity-profile %} {% with entity_profile=rec.entity_profile.first entity_profile_title=rec.name %} {% if entity_profile %} -
{% include 'peachjam/_entity_profile.html' %}
+ {% include 'peachjam/_entity_profile.html' %} {% endif %} {% endwith %} {% endblock %} diff --git a/liiweb/templates/liiweb/legislation_list.html b/liiweb/templates/liiweb/legislation_list.html index 6c3e5ab70..28006e3c0 100644 --- a/liiweb/templates/liiweb/legislation_list.html +++ b/liiweb/templates/liiweb/legislation_list.html @@ -4,7 +4,9 @@ {% trans 'Legislation' %} {% endblock %} {% block page-title %} -

{% trans 'Legislation' %}

+ {% if not entity_profile %} +

{% trans 'Legislation' %}

+ {% endif %} {% endblock %} {% block alerts %} {% if view.variant == 'repealed' %} @@ -59,8 +61,3 @@

{% trans 'Legislation' %}

{% endblock %} -{% block entity-profile %} - {% if entity_profile %} -
{% include 'peachjam/_entity_profile.html' %}
- {% endif %} -{% endblock %} diff --git a/liiweb/views/legislation.py b/liiweb/views/legislation.py index 783c4a0f0..6bda8b785 100644 --- a/liiweb/views/legislation.py +++ b/liiweb/views/legislation.py @@ -7,16 +7,13 @@ from django.views.generic import TemplateView from peachjam.helpers import chunks, get_language -from peachjam.models import JurisdictionProfile, Legislation, Locality, pj_settings -from peachjam.views import FilteredDocumentListView +from peachjam.models import JurisdictionProfile, Locality, pj_settings +from peachjam.views import LegislationListView as BaseLegislationListView -class LegislationListView(FilteredDocumentListView): +class LegislationListView(BaseLegislationListView): template_name = "liiweb/legislation_list.html" variant = "current" - navbar_link = "legislation" - model = Legislation - queryset = Legislation.objects.prefetch_related("work", "labels") latest_expression_only = True form_defaults = None @@ -58,28 +55,27 @@ def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) self.add_children(context["documents"]) - site_jurisdictions = pj_settings().document_jurisdictions.all() - if site_jurisdictions.count() == 1: - jurisdiction_profile = JurisdictionProfile.objects.filter( - jurisdiction=site_jurisdictions.first() - ).first() - if jurisdiction_profile: - context["entity_profile"] = jurisdiction_profile.entity_profile.first() - context["entity_profile_title"] = jurisdiction_profile.jurisdiction.name - - context["doc_type"] = "Legislation" # for quick search context["doc_table_toggle"] = True context["doc_table_citations"] = True context["doc_table_show_doc_type"] = False context["doc_table_show_court"] = False context["doc_table_show_author"] = False context["doc_table_show_jurisdiction"] = False - context["help_link"] = "legislation/" context["documents"] = self.group_documents(context["documents"]) return context + def add_entity_profile(self, context): + site_jurisdictions = pj_settings().document_jurisdictions.all() + if site_jurisdictions.count() == 1: + jurisdiction_profile = JurisdictionProfile.objects.filter( + jurisdiction=site_jurisdictions.first() + ).first() + if jurisdiction_profile: + context["entity_profile"] = jurisdiction_profile.entity_profile.first() + context["entity_profile_title"] = jurisdiction_profile.jurisdiction.name + def add_children(self, queryset): # pull in children (subleg) parents = list( @@ -87,7 +83,7 @@ def add_children(self, queryset): ) children = defaultdict(list) - children_qs = Legislation.objects.filter( + children_qs = self.queryset.filter( parent_work_id__in=parents, repealed=False, metadata_json__principal=True ).order_by("-date") children_qs = children_qs.preferred_language(get_language(self.request)) diff --git a/peachjam/migrations/0155_entityprofile_title.py b/peachjam/migrations/0155_entityprofile_title.py new file mode 100644 index 000000000..dee5587cb --- /dev/null +++ b/peachjam/migrations/0155_entityprofile_title.py @@ -0,0 +1,20 @@ +# Generated by Django 4.2.14 on 2024-09-05 08:27 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("peachjam", "0154_backfill_nature_elasticsearch"), + ] + + operations = [ + migrations.AddField( + model_name="entityprofile", + name="title", + field=models.CharField( + blank=True, max_length=1024, null=True, verbose_name="Title" + ), + ), + ] diff --git a/peachjam/models/profile.py b/peachjam/models/profile.py index da7aff370..d2ccbe342 100644 --- a/peachjam/models/profile.py +++ b/peachjam/models/profile.py @@ -10,6 +10,7 @@ def entity_profile_photo_filename(instance, filename): class EntityProfile(models.Model): + title = models.CharField(_("Title"), max_length=1024, null=True, blank=True) about_html = models.TextField(_("about HTML"), null=True, blank=True) website_url = models.URLField(_("website URL"), null=True, blank=True) address = models.TextField(_("address"), null=True, blank=True) diff --git a/peachjam/static/stylesheets/_global.scss b/peachjam/static/stylesheets/_global.scss index 6c7b41491..cc428258d 100644 --- a/peachjam/static/stylesheets/_global.scss +++ b/peachjam/static/stylesheets/_global.scss @@ -92,11 +92,6 @@ footer { } } -.breadcrumb { - padding-top: 1rem; - margin-bottom: 0; -} - // xs btn .btn.btn-xs { @include button-size(0.125rem, 0.25rem, $btn-font-size-sm, $btn-border-radius-sm); @@ -194,3 +189,7 @@ a:visited { #skip-links a:focus { top: -1px; } + +.breadcrumb { + padding-top: 1rem; +} diff --git a/peachjam/static/stylesheets/_variables.scss b/peachjam/static/stylesheets/_variables.scss index e46bbf5c4..f46116c21 100644 --- a/peachjam/static/stylesheets/_variables.scss +++ b/peachjam/static/stylesheets/_variables.scss @@ -28,3 +28,5 @@ $visited-link: #1A77F2 !default; --diff-green-color: #{$diff-green-color}; --diff-red-color: #{$diff-red-color}; } + +$breadcrumb-margin-bottom: 1rem !default; diff --git a/peachjam/static/stylesheets/components/_entity-profile.scss b/peachjam/static/stylesheets/components/_entity-profile.scss index 9e592f3f9..0b6e10661 100644 --- a/peachjam/static/stylesheets/components/_entity-profile.scss +++ b/peachjam/static/stylesheets/components/_entity-profile.scss @@ -1,7 +1,6 @@ .entity-profile { @extend .bg-light; - - margin-top: -1rem; + margin-bottom: 1rem; &.has-background-photo { background-color: transparent !important; diff --git a/peachjam/templates/peachjam/_entity_profile.html b/peachjam/templates/peachjam/_entity_profile.html index e7d0a499b..334b2e127 100644 --- a/peachjam/templates/peachjam/_entity_profile.html +++ b/peachjam/templates/peachjam/_entity_profile.html @@ -15,7 +15,7 @@ loading="lazy"/> {% endif %}
-

{{ entity_profile_title }}

+

{{ entity_profile_title|default:entity_profile.title }}

{% if entity_profile.about_html %}
{{ entity_profile.about_html|safe }}
{% endif %}
{% if entity_profile.address %} diff --git a/peachjam/templates/peachjam/author_detail.html b/peachjam/templates/peachjam/author_detail.html index a0d4fe659..b6dda3dee 100644 --- a/peachjam/templates/peachjam/author_detail.html +++ b/peachjam/templates/peachjam/author_detail.html @@ -2,7 +2,9 @@ {% load i18n %} {% block title %}{{ author }}{% endblock %} {% block page-title %} -

{% blocktrans %} Documents by {{ author }} {% endblocktrans %}

+ {% if not entity_profile %} +

{% blocktrans %} Documents by {{ author }} {% endblocktrans %}

+ {% endif %} {% endblock %} {% block entity-profile %} {% with entity_profile_title=author entity_profile=author.entity_profile.first %} diff --git a/peachjam/templates/peachjam/court_detail.html b/peachjam/templates/peachjam/court_detail.html index efdd6403d..b967cc3a6 100644 --- a/peachjam/templates/peachjam/court_detail.html +++ b/peachjam/templates/peachjam/court_detail.html @@ -34,14 +34,9 @@
{% endblock %} -{% block entity-profile %} - {% with entity_profile=court.entity_profile.first entity_profile_title=court.name %} - {% if entity_profile %} -
{% include 'peachjam/_entity_profile.html' %}
- {% endif %} - {% endwith %} +{% block page-title %} + {% if not entity_profile %}

{{ page_title }}

{% endif %} {% endblock %} -{% block page-title %}

{{ page_title }}

{% endblock %} {% block page-header %} {{ block.super }} {% block court_list %} diff --git a/peachjam/templates/peachjam/gazette_list.html b/peachjam/templates/peachjam/gazette_list.html index f3f9c8cdb..41dd9579a 100644 --- a/peachjam/templates/peachjam/gazette_list.html +++ b/peachjam/templates/peachjam/gazette_list.html @@ -1,89 +1,89 @@ -{% extends "peachjam/layouts/main.html" %} +{% extends "peachjam/layouts/document_list.html" %} {% load i18n %} {% block title %} {{ place|default_if_none:"" }} {% trans 'Gazettes' %} {{ year }} {% endblock %} -{% block page-content %} -
-
- {% block breadcrumbs %} - - {% endblock %} - {% block page-title %} -

- {% if place %}{{ place }}{% endif %} - {% trans 'Gazettes' %} -

- {% endblock %} - {% block count-and-search %} - {% block localities %} - {% if localities %} - {% include 'peachjam/_gazette_localities.html' %} - {% endif %} - {% endblock %} - {% include 'peachjam/_count_and_search.html' %} - {% endblock %} - {% if doc_count %} - {% block years-list %} -
- {% for year in years %} -
-
-
-

- {% block gazette-year-link %} - {% if locality %} - {{ year.year }} - {% elif country %} - {{ year.year }} - {% else %} - {{ year.year }} - {% endif %} - {% endblock %} -

-
- {% blocktrans trimmed count num_gazettes=year.count %} - {{ num_gazettes }} gazette - {% plural %} - {{ num_gazettes }} gazettes - {% endblocktrans %} -
- {% block monthly-chart %} - {% if locality %} - {% url 'gazettes_by_year' locality.place_code year.year as url %} - {% elif country %} - {% url 'gazettes_by_year' country.pk.lower year.year as url %} - {% else %} - {% url 'gazettes_by_year' year.year as url %} - {% endif %} - {% include 'peachjam/_monthly_column_chart.html' %} - {% endblock %} -
+{% block breadcrumbs %} +
+ +
+{% endblock %} +{% block page-title %} + {% if not entity_profile %} +

+ {% if place %}{{ place }}{% endif %} + {% trans 'Gazettes' %} +

+ {% endif %} +{% endblock %} +{% block count-and-search %} + {% block localities %} + {% if localities %} + {% include 'peachjam/_gazette_localities.html' %} + {% endif %} + {% endblock %} + {% include 'peachjam/_count_and_search.html' %} +{% endblock %} +{% block document-table %} + {% if doc_count %} + {% block years-list %} +
+ {% for year in years %} +
+
+
+

+ {% block gazette-year-link %} + {% if locality %} + {{ year.year }} + {% elif country %} + {{ year.year }} + {% else %} + {{ year.year }} + {% endif %} + {% endblock %} +

+
+ {% blocktrans trimmed count num_gazettes=year.count %} + {{ num_gazettes }} gazette + {% plural %} + {{ num_gazettes }} gazettes + {% endblocktrans %}
+ {% block monthly-chart %} + {% if locality %} + {% url 'gazettes_by_year' locality.place_code year.year as url %} + {% elif country %} + {% url 'gazettes_by_year' country.pk.lower year.year as url %} + {% else %} + {% url 'gazettes_by_year' year.year as url %} + {% endif %} + {% include 'peachjam/_monthly_column_chart.html' %} + {% endblock %}
- {% endfor %} +
- {% endblock %} - {% endif %} -
-
+ {% endfor %} +
+ {% endblock %} + {% endif %} {% endblock %} diff --git a/peachjam/templates/peachjam/judgment_list.html b/peachjam/templates/peachjam/judgment_list.html index 2d7e280ef..1e7b44a39 100644 --- a/peachjam/templates/peachjam/judgment_list.html +++ b/peachjam/templates/peachjam/judgment_list.html @@ -1,28 +1,19 @@ -{% extends "peachjam/layouts/main.html" %} +{% extends "peachjam/layouts/document_list.html" %} {% load i18n %} {% block title %} {% trans 'Judgments' %} {% endblock %} -{% block page-content %} -
-
- {% block page-header %} - {% block page-title %} -

{% trans 'Judgments' %}

- {% endblock %} - {% block count-and-search %} - {% include 'peachjam/_count_and_search.html' %} - {% endblock %} - {% endblock %} - {% include 'peachjam/_court_list.html' %} -

- {% if title %} - {{ title }} - {% else %} - {% trans 'Recent judgments' %} - {% endif %} -

- {% include 'peachjam/_recent_document_list.html' with documents=recent_judgments %} -
-
+{% block page-title %} +

{% trans 'Judgments' %}

+{% endblock %} +{% block document-table %} + {% include 'peachjam/_court_list.html' %} +

+ {% if title %} + {{ title }} + {% else %} + {% trans 'Recent judgments' %} + {% endif %} +

+ {% include 'peachjam/_recent_document_list.html' with documents=recent_judgments %} {% endblock %} diff --git a/peachjam/templates/peachjam/layouts/document_list.html b/peachjam/templates/peachjam/layouts/document_list.html index dea61d2a9..e80f2b368 100644 --- a/peachjam/templates/peachjam/layouts/document_list.html +++ b/peachjam/templates/peachjam/layouts/document_list.html @@ -5,11 +5,17 @@ {% endblock %} {% block page-content %} {% block breadcrumbs %}{% endblock %} - {% block entity-profile %}{% endblock %} + {% block entity-profile %} + {% if entity_profile %} + {% include 'peachjam/_entity_profile.html' %} + {% endif %} + {% endblock %}
{% block page-header %} {% block page-title %} -

{% trans 'Documents' %}

+ {% if not entity_profile %} +

{% trans 'Documents' %}

+ {% endif %} {% endblock %} {% block count-and-search %} {% include 'peachjam/_count_and_search.html' %} diff --git a/peachjam/templates/peachjam/place_detail.html b/peachjam/templates/peachjam/place_detail.html index 464062a8e..6faaaf85c 100644 --- a/peachjam/templates/peachjam/place_detail.html +++ b/peachjam/templates/peachjam/place_detail.html @@ -1,4 +1,6 @@ {% extends 'peachjam/layouts/document_list.html' %} {% load i18n %} {% block title %}{{ place }}{% endblock %} -{% block page-title %}

{{ place }}

{% endblock %} +{% block page-title %} + {% if not entity_profile %}

{{ place }}

{% endif %} +{% endblock %} diff --git a/peachjam/templates/peachjam/taxonomy_detail.html b/peachjam/templates/peachjam/taxonomy_detail.html index a4395d671..e73d60074 100644 --- a/peachjam/templates/peachjam/taxonomy_detail.html +++ b/peachjam/templates/peachjam/taxonomy_detail.html @@ -1,7 +1,9 @@ {% extends 'peachjam/layouts/document_list.html' %} {% load peachjam i18n %} {% block title %}{{ taxonomy.name }}{% endblock %} -{% block page-title %}

{{ taxonomy.name }}

{% endblock %} +{% block page-title %} + {% if not entity_profile %}

{{ taxonomy.name }}

{% endif %} +{% endblock %} {% block breadcrumbs %}