From e274c3dc0086986cc8b66d81f2fe76001013feea Mon Sep 17 00:00:00 2001 From: Greg Kempe Date: Thu, 5 Sep 2024 10:29:07 +0200 Subject: [PATCH 1/7] support entity profiles in more places also fix an n+1 legislation list view builds on peachjam's view --- liiweb/templates/liiweb/legislation_list.html | 5 - liiweb/views/legislation.py | 32 ++-- peachjam/models/profile.py | 1 + .../templates/peachjam/_entity_profile.html | 2 +- peachjam/templates/peachjam/gazette_list.html | 160 +++++++++--------- .../templates/peachjam/judgment_list.html | 37 ++-- .../peachjam/layouts/document_list.html | 6 +- peachjam/views/gazette.py | 4 + peachjam/views/generic_views.py | 7 +- peachjam/views/judgment.py | 4 + peachjam/views/legislation.py | 4 +- 11 files changed, 129 insertions(+), 133 deletions(-) diff --git a/liiweb/templates/liiweb/legislation_list.html b/liiweb/templates/liiweb/legislation_list.html index 6c3e5ab70..f1e79fcf4 100644 --- a/liiweb/templates/liiweb/legislation_list.html +++ b/liiweb/templates/liiweb/legislation_list.html @@ -59,8 +59,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/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/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/gazette_list.html b/peachjam/templates/peachjam/gazette_list.html index 0c735a179..c37096c20 100644 --- a/peachjam/templates/peachjam/gazette_list.html +++ b/peachjam/templates/peachjam/gazette_list.html @@ -1,91 +1,87 @@ -{% 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 %} - {% if place %} - +{% block breadcrumbs %} + {% if place %} + + {% endif %} +{% 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 %} +{% 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..202c15b38 100644 --- a/peachjam/templates/peachjam/layouts/document_list.html +++ b/peachjam/templates/peachjam/layouts/document_list.html @@ -5,7 +5,11 @@ {% 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 %} diff --git a/peachjam/views/gazette.py b/peachjam/views/gazette.py index 80adf1e7d..86f67a0c0 100644 --- a/peachjam/views/gazette.py +++ b/peachjam/views/gazette.py @@ -96,6 +96,7 @@ def get_context_data(self, **kwargs): context["doc_count_noun"] = _("gazette") context["doc_count_noun_plural"] = _("gazettes") context["doc_type"] = "Gazette" + self.add_entity_profile(context) return context @@ -110,6 +111,9 @@ def get_localities(self, context): return Locality.objects.filter(pk__in=locality_ids) return [] + def add_entity_profile(self, context): + pass + class GazetteYearView(YearMixin, FilteredDocumentListView): model = Gazette diff --git a/peachjam/views/generic_views.py b/peachjam/views/generic_views.py index 5c548cc2f..d114dcf48 100644 --- a/peachjam/views/generic_views.py +++ b/peachjam/views/generic_views.py @@ -53,13 +53,18 @@ def get_queryset(self): return qs.preferred_language(get_language(self.request)) def get_context_data(self, *args, **kwargs): - return super().get_context_data( + context = super().get_context_data( doc_table_show_jurisdiction=True, doc_count_noun=_("document"), doc_count_noun_plural=_("documents"), *args, **kwargs, ) + self.add_entity_profile(context) + return context + + def add_entity_profile(self, context): + pass def group_documents(self, documents, group_by): if not group_by: diff --git a/peachjam/views/judgment.py b/peachjam/views/judgment.py index b45792cfa..fcd9d64eb 100644 --- a/peachjam/views/judgment.py +++ b/peachjam/views/judgment.py @@ -25,8 +25,12 @@ def get_context_data(self, **kwargs): context["doc_count_noun"] = _("judgment") context["doc_count_noun_plural"] = _("judgments") context["help_link"] = "judgments/courts" + self.add_entity_profile(context) return context + def add_entity_profile(self, context): + pass + @registry.register_doc_type("judgment") class JudgmentDetailView(BaseDocumentDetailView): diff --git a/peachjam/views/legislation.py b/peachjam/views/legislation.py index d46752e7f..d1461c280 100644 --- a/peachjam/views/legislation.py +++ b/peachjam/views/legislation.py @@ -17,8 +17,8 @@ class LegislationListView(FilteredDocumentListView): model = Legislation template_name = "peachjam/legislation_list.html" navbar_link = "legislation" - queryset = Legislation.objects.prefetch_related("work") - extra_context = {"doc_type": "Legislation"} + queryset = Legislation.objects.prefetch_related("work", "labels") + extra_context = {"doc_type": "Legislation", "help_link": "legislation/"} form_defaults = {"sort": "title"} From c34066763152ce3a02cd6c70a2b23a4e24237ed2 Mon Sep 17 00:00:00 2001 From: Greg Kempe Date: Thu, 5 Sep 2024 12:26:45 +0200 Subject: [PATCH 2/7] don't show headings if there is an entity profile --- liiweb/templates/liiweb/legislation_list.html | 4 +++- peachjam/templates/peachjam/author_detail.html | 4 +++- peachjam/templates/peachjam/court_detail.html | 4 +++- peachjam/templates/peachjam/gazette_list.html | 10 ++++++---- peachjam/templates/peachjam/layouts/document_list.html | 4 +++- peachjam/templates/peachjam/place_detail.html | 4 +++- peachjam/templates/peachjam/taxonomy_detail.html | 4 +++- 7 files changed, 24 insertions(+), 10 deletions(-) diff --git a/liiweb/templates/liiweb/legislation_list.html b/liiweb/templates/liiweb/legislation_list.html index f1e79fcf4..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' %} 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..091082d88 100644 --- a/peachjam/templates/peachjam/court_detail.html +++ b/peachjam/templates/peachjam/court_detail.html @@ -41,7 +41,9 @@ {% endif %} {% endwith %} {% endblock %} -{% block page-title %}

{{ page_title }}

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

{{ page_title }}

{% endif %} +{% 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 c37096c20..c603e7e22 100644 --- a/peachjam/templates/peachjam/gazette_list.html +++ b/peachjam/templates/peachjam/gazette_list.html @@ -28,10 +28,12 @@ {% endif %} {% endblock %} {% block page-title %} -

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

+ {% if not entity_profile %} +

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

+ {% endif %} {% endblock %} {% block count-and-search %} {% block localities %} diff --git a/peachjam/templates/peachjam/layouts/document_list.html b/peachjam/templates/peachjam/layouts/document_list.html index 202c15b38..78c75d9d1 100644 --- a/peachjam/templates/peachjam/layouts/document_list.html +++ b/peachjam/templates/peachjam/layouts/document_list.html @@ -13,7 +13,9 @@
{% 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..b08b14784 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 %}
{% endblock %} {% block page-title %} {% if not entity_profile %} From 0b1c8d3cfc04fe11d44e139730dcd60463736baf Mon Sep 17 00:00:00 2001 From: Greg Kempe Date: Thu, 5 Sep 2024 14:30:43 +0200 Subject: [PATCH 4/7] missing migration --- .../migrations/0152_entityprofile_title.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 peachjam/migrations/0152_entityprofile_title.py diff --git a/peachjam/migrations/0152_entityprofile_title.py b/peachjam/migrations/0152_entityprofile_title.py new file mode 100644 index 000000000..88a55255b --- /dev/null +++ b/peachjam/migrations/0152_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", "0151_folder_peachjamsettings_allow_save_documents_and_more"), + ] + + operations = [ + migrations.AddField( + model_name="entityprofile", + name="title", + field=models.CharField( + blank=True, max_length=1024, null=True, verbose_name="Title" + ), + ), + ] From 787ae48dec79ca372c3bd3c019745367ee944761 Mon Sep 17 00:00:00 2001 From: Greg Kempe Date: Thu, 5 Sep 2024 15:49:56 +0200 Subject: [PATCH 5/7] correct padding and margins around entity profiles breadcrumbs must have padding at the top, and margin below (which can collapse into margins of the h1 on the page, if necessary) --- .../templates/africanlii/au_institution_detail.html | 2 +- africanlii/templates/africanlii/au_organ_detail.html | 2 +- africanlii/templates/africanlii/member_state_detail.html | 2 +- .../africanlii/regional_economic_community_detail.html | 2 +- peachjam/static/stylesheets/_global.scss | 9 ++++----- peachjam/static/stylesheets/_variables.scss | 2 ++ .../static/stylesheets/components/_entity-profile.scss | 3 +-- peachjam/templates/peachjam/court_detail.html | 2 +- peachjam/templates/peachjam/layouts/document_list.html | 2 +- peachjam/templates/peachjam/taxonomy_detail.html | 2 +- 10 files changed, 14 insertions(+), 14 deletions(-) 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/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/court_detail.html b/peachjam/templates/peachjam/court_detail.html index 091082d88..f80ae63a9 100644 --- a/peachjam/templates/peachjam/court_detail.html +++ b/peachjam/templates/peachjam/court_detail.html @@ -37,7 +37,7 @@ {% block entity-profile %} {% with entity_profile=court.entity_profile.first entity_profile_title=court.name %} {% if entity_profile %} -
{% include 'peachjam/_entity_profile.html' %}
+ {% include 'peachjam/_entity_profile.html' %} {% endif %} {% endwith %} {% endblock %} diff --git a/peachjam/templates/peachjam/layouts/document_list.html b/peachjam/templates/peachjam/layouts/document_list.html index 78c75d9d1..e80f2b368 100644 --- a/peachjam/templates/peachjam/layouts/document_list.html +++ b/peachjam/templates/peachjam/layouts/document_list.html @@ -7,7 +7,7 @@ {% block breadcrumbs %}{% endblock %} {% block entity-profile %} {% if entity_profile %} -
{% include 'peachjam/_entity_profile.html' %}
+ {% include 'peachjam/_entity_profile.html' %} {% endif %} {% endblock %}
diff --git a/peachjam/templates/peachjam/taxonomy_detail.html b/peachjam/templates/peachjam/taxonomy_detail.html index b08b14784..e73d60074 100644 --- a/peachjam/templates/peachjam/taxonomy_detail.html +++ b/peachjam/templates/peachjam/taxonomy_detail.html @@ -26,7 +26,7 @@ {% block entity-profile %} {% if entity_profile %} {% with entity_profile_title=taxonomy.name %} -
{% include 'peachjam/_entity_profile.html' %}
+ {% include 'peachjam/_entity_profile.html' %} {% endwith %} {% endif %} {% endblock %} From 32a194eea666433bef60106c266d941fbf4c08c2 Mon Sep 17 00:00:00 2001 From: Greg Kempe Date: Thu, 5 Sep 2024 15:55:48 +0200 Subject: [PATCH 6/7] fix court entity profile lookup --- peachjam/templates/peachjam/court_detail.html | 7 ------- peachjam/views/courts.py | 4 ++++ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/peachjam/templates/peachjam/court_detail.html b/peachjam/templates/peachjam/court_detail.html index f80ae63a9..b967cc3a6 100644 --- a/peachjam/templates/peachjam/court_detail.html +++ b/peachjam/templates/peachjam/court_detail.html @@ -34,13 +34,6 @@
{% 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 %} -{% endblock %} {% block page-title %} {% if not entity_profile %}

{{ page_title }}

{% endif %} {% endblock %} diff --git a/peachjam/views/courts.py b/peachjam/views/courts.py index 175f78872..04d12815e 100644 --- a/peachjam/views/courts.py +++ b/peachjam/views/courts.py @@ -168,6 +168,10 @@ def get_context_data(self, **kwargs): context["all_years_url"] = self.court.get_absolute_url() return context + def add_entity_profile(self, context): + context["entity_profile"] = self.court.entity_profile.first() + context["entity_profile_title"] = self.court.name + class CourtYearView(YearMixin, CourtDetailView): def get_context_data(self, **kwargs): From 0d28142bf65b98d63ff5c0c0e3e653a131fe4667 Mon Sep 17 00:00:00 2001 From: Greg Kempe Date: Thu, 5 Sep 2024 16:49:43 +0200 Subject: [PATCH 7/7] fix migration --- ...{0152_entityprofile_title.py => 0155_entityprofile_title.py} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename peachjam/migrations/{0152_entityprofile_title.py => 0155_entityprofile_title.py} (83%) diff --git a/peachjam/migrations/0152_entityprofile_title.py b/peachjam/migrations/0155_entityprofile_title.py similarity index 83% rename from peachjam/migrations/0152_entityprofile_title.py rename to peachjam/migrations/0155_entityprofile_title.py index 88a55255b..dee5587cb 100644 --- a/peachjam/migrations/0152_entityprofile_title.py +++ b/peachjam/migrations/0155_entityprofile_title.py @@ -6,7 +6,7 @@ class Migration(migrations.Migration): dependencies = [ - ("peachjam", "0151_folder_peachjamsettings_allow_save_documents_and_more"), + ("peachjam", "0154_backfill_nature_elasticsearch"), ] operations = [