Use richtext for subtitle

This commit is contained in:
Jake Howard 2022-09-03 17:00:09 +01:00
parent f8f0b6ce82
commit a053e27833
Signed by: jake
GPG key ID: 57AFB45680EDD477
7 changed files with 82 additions and 5 deletions

View file

@ -0,0 +1,19 @@
# Generated by Django 4.0.6 on 2022-09-03 15:44
import wagtail.fields
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("blog", "0022_alter_blogpostcollectionlistpage_body_and_more"),
]
operations = [
migrations.AlterField(
model_name="blogpostpage",
name="subtitle",
field=wagtail.fields.RichTextField(blank=True),
),
]

View file

@ -0,0 +1,19 @@
# Generated by Django 4.0.6 on 2022-09-03 15:44
import wagtail.fields
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("common", "0022_footersetting"),
]
operations = [
migrations.AlterField(
model_name="contentpage",
name="subtitle",
field=wagtail.fields.RichTextField(blank=True),
),
]

View file

@ -13,7 +13,7 @@ from django.utils.text import slugify
from wagtail.admin.panels import FieldPanel
from wagtail.contrib.routable_page.models import RoutablePageMixin, route
from wagtail.contrib.settings.models import BaseSetting, register_setting
from wagtail.fields import StreamField
from wagtail.fields import RichTextField, StreamField
from wagtail.images import get_image_model_string
from wagtail.images.views.serve import generate_image_url
from wagtail.models import Page, PageQuerySet
@ -24,6 +24,7 @@ from wagtailmetadata.models import MetadataMixin
from website.contrib.unsplash.widgets import UnsplashPhotoChooser
from .rich_text import RICH_TEXT_FEATURES_PLAIN
from .serializers import PaginationSerializer
from .streamfield import add_heading_anchors, get_blocks, get_content_html
from .utils import (
@ -62,7 +63,7 @@ class BasePage(Page):
class BaseContentPage(BasePage, MetadataMixin):
subtitle = models.CharField(max_length=255, blank=True)
subtitle = RichTextField(blank=True, features=RICH_TEXT_FEATURES_PLAIN)
hero_image = models.ForeignKey(
get_image_model_string(), null=True, blank=True, on_delete=models.SET_NULL
)

View file

@ -1,6 +1,6 @@
{% extends "base.html" %}
{% load wagtailmetadata_tags %}
{% load wagtailmetadata_tags wagtailcore_tags %}
{% block body_class %}{{ page.body_class }}{% endblock %}
@ -29,7 +29,7 @@
{% include "common/breadcrumbs.html" with parents=page.get_parent_pages %}
<h1 class="title is-spaced">{{ page.hero_title }}</h1>
{% if page.subtitle %}
<h2 class="subtitle">{{ page.subtitle }}</h2>
<h2 class="subtitle">{{ page.subtitle|richtext }}</h2>
{% endif %}
{% include "common/content-details.html" %}

View file

@ -0,0 +1,19 @@
# Generated by Django 4.0.6 on 2022-09-03 15:44
import wagtail.fields
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("contact", "0007_onlineaccount_icon"),
]
operations = [
migrations.AlterField(
model_name="contactpage",
name="subtitle",
field=wagtail.fields.RichTextField(blank=True),
),
]

View file

@ -0,0 +1,19 @@
# Generated by Django 4.0.6 on 2022-09-03 15:44
import wagtail.fields
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("search", "0005_alter_searchpage_body"),
]
operations = [
migrations.AlterField(
model_name="searchpage",
name="subtitle",
field=wagtail.fields.RichTextField(blank=True),
),
]

View file

@ -49,7 +49,7 @@ class SpotifyPlaylistPage(BaseContentPage):
)
@cached_property
def subtitle(self) -> int:
def subtitle(self) -> str:
return self.playlist_data["description"]
@cached_property