From 48db6635c868a63a61f5687fb692335fe77b2146 Mon Sep 17 00:00:00 2001 From: Ben Silverman Date: Fri, 13 Sep 2024 12:58:49 -0400 Subject: [PATCH] Update homepage model/template to add featured story --- .../0005_homepage_featured_story.py | 43 +++++++++++++++++++ apps/cms/models.py | 26 ++++++++++- apps/templates/_home/_featured_story.html | 18 +++++--- apps/templates/cms/home_page.html | 14 ++++-- 4 files changed, 91 insertions(+), 10 deletions(-) create mode 100644 apps/cms/migrations/0005_homepage_featured_story.py diff --git a/apps/cms/migrations/0005_homepage_featured_story.py b/apps/cms/migrations/0005_homepage_featured_story.py new file mode 100644 index 00000000..7b84de52 --- /dev/null +++ b/apps/cms/migrations/0005_homepage_featured_story.py @@ -0,0 +1,43 @@ +# Generated by Django 3.2.25 on 2024-09-13 16:25 + +from django.db import migrations, models + +class Migration(migrations.Migration): + + dependencies = [ + ("cms", "0004_auto_20200224_2038"), + ] + + operations = [ + migrations.AddField( + model_name="homepage", + name="featured_story_image", + field=models.ForeignKey( + blank=True, + help_text="Thumbnail image for the featured story", + null=True, + on_delete=models.deletion.SET_NULL, + related_name="+", + to="wagtailimages.image", + ), + ), + migrations.AddField( + model_name="homepage", + name="featured_story_summary", + field=models.TextField( + blank=True, help_text="A summary or excerpt of the featured story" + ), + ), + migrations.AddField( + model_name="homepage", + name="featured_story_title", + field=models.CharField( + blank=True, help_text="Title of the featured story", max_length=255 + ), + ), + migrations.AddField( + model_name="homepage", + name="featured_story_url", + field=models.URLField(blank=True, help_text="Link to the featured story"), + ), + ] diff --git a/apps/cms/models.py b/apps/cms/models.py index b12162f6..c035534f 100644 --- a/apps/cms/models.py +++ b/apps/cms/models.py @@ -3,7 +3,7 @@ from modelcluster.fields import ParentalManyToManyField from wagtail.models import Page from wagtail.fields import RichTextField, StreamField -from wagtail.admin.panels import FieldPanel +from wagtail.admin.panels import FieldPanel, MultiFieldPanel from wagtailautocomplete.edit_handlers import AutocompletePanel from django.db import models from apps.cms.blocks import BaseStreamBlock @@ -195,6 +195,24 @@ class HomePage(Page): collections = Collection.objects.all()[:8] volumes = Manifest.objects.all()[:8] + featured_story_title = models.CharField( + help_text="Title of the featured story", blank=True, max_length=255 + ) + featured_story_summary = models.TextField( + help_text="A summary or excerpt of the featured story", blank=True + ) + featured_story_image = models.ForeignKey( + 'wagtailimages.Image', + null=True, + blank=True, + on_delete=models.SET_NULL, + related_name='+', + help_text="Thumbnail image for the featured story", + ) + featured_story_url = models.URLField( + help_text="Link to the featured story", blank=True + ) + content_panels = Page.content_panels + [ FieldPanel('tagline', classname="full"), FieldPanel('content_display', classname="full"), @@ -202,6 +220,12 @@ class HomePage(Page): FieldPanel('featured_collections_sort_order', classname="full"), AutocompletePanel('featured_volumes', target_model="manifests.Manifest"), FieldPanel('featured_volumes_sort_order', classname="full"), + MultiFieldPanel(children=[ + FieldPanel('featured_story_title'), + FieldPanel('featured_story_summary'), + FieldPanel('featured_story_image'), + FieldPanel('featured_story_url'), + ], heading='Featured story (optional)'), ] def featured_volume_count(self): diff --git a/apps/templates/_home/_featured_story.html b/apps/templates/_home/_featured_story.html index 8b02ff82..be93df19 100644 --- a/apps/templates/_home/_featured_story.html +++ b/apps/templates/_home/_featured_story.html @@ -1,16 +1,24 @@ +{% load wagtailimages_tags %} +
+ {% if page.featured_story_image %}
- Image + {% image page.featured_story_image max-700x700 class="uk-width-1-1" %}
-

Reviving Sacred Song: The Sounding Spirit Collaborative and Its Impact on American Vernacular Music History

+ {% else %} +
+ {% endif%} +

{{ page.featured_story_title }}

- The Sounding Spirit Collaborative engages sacred music from a dynamic era of American history. We make accessible and interpret historical sacred vernacular songbooks printed across territories and states spanning the southern United States from 1850 to 1925. Our ongoing scholarly edition and digital library work leverages collaborations between scholars, practitioners, librarians, and technologists to bring interdisciplinary, multi-modal expertise to the study and dissemination of these music books. These collaborations invite both scholarly and confessional reconsiderations of the role of sacred song in the lived experience of diverse communities. Working with texts and tunes often marginalized in music history, singers and scholars join Sounding Spirit in claiming a more diverse canon of southern vernacular sacred music. + {{ page.featured_story_summary }}

- Read Full Story + + Read Full Story +
-
\ No newline at end of file +
diff --git a/apps/templates/cms/home_page.html b/apps/templates/cms/home_page.html index e2e82daf..ad21cf32 100644 --- a/apps/templates/cms/home_page.html +++ b/apps/templates/cms/home_page.html @@ -13,9 +13,15 @@
{% include '_home/_nav.html' %} {% include '_home/_hero.html' %} - {% include '_home/_featured_story.html' %} - {% include '_home/_featured_volumes.html' %} - {% include '_home/_featured_collections.html' %} + {% if page.featured_story_title and page.featured_story_url %} + {% include '_home/_featured_story.html' %} + {% endif %} + {% if page.featured_volumes.all.count != 0 %} + {% include '_home/_featured_volumes.html' %} + {% endif %} + {% if page.featured_collections.all.count != 0 %} + {% include '_home/_featured_collections.html' %} + {% endif %} {% include '_home/_video.html' %} {% include '_home/_highlights.html' %} {% include '_home/_footer.html' %} @@ -23,4 +29,4 @@
{% endif %} -{% endblock %} \ No newline at end of file +{% endblock %}