Restructure fields in editor pages

Move as much as possible out of the "Content" tab, so that's just about
the actual content
This commit is contained in:
Jake Howard 2022-09-21 13:30:06 +01:00
parent 2d537d3b10
commit bccc948995
Signed by: jake
GPG key ID: 57AFB45680EDD477
3 changed files with 17 additions and 8 deletions

View file

@ -61,7 +61,7 @@ class BlogPostPage(BaseContentPage):
tags = ParentalManyToManyField("blog.BlogPostTagPage", blank=True)
date = models.DateField(default=timezone.now)
content_panels = BaseContentPage.content_panels + [
promote_panels = BaseContentPage.promote_panels + [
FieldPanel("date"),
AutocompletePanel("tags"),
]

View file

@ -12,7 +12,7 @@ from django.utils.decorators import method_decorator
from django.utils.functional import cached_property, classproperty
from django.utils.text import slugify
from django.views.decorators.cache import cache_page
from wagtail.admin.panels import FieldPanel
from wagtail.admin.panels import FieldPanel, MultiFieldPanel
from wagtail.contrib.routable_page.models import RoutablePageMixin, route
from wagtail.contrib.settings.models import BaseSetting, register_setting
from wagtail.fields import RichTextField, StreamField
@ -75,8 +75,13 @@ class BaseContentPage(BasePage, MetadataMixin):
content_panels = BasePage.content_panels + [
FieldPanel("subtitle"),
FieldPanel("hero_image"),
FieldPanel("hero_unsplash_photo", widget=UnsplashPhotoChooser),
MultiFieldPanel(
[
FieldPanel("hero_image"),
FieldPanel("hero_unsplash_photo", widget=UnsplashPhotoChooser),
],
heading="Hero image",
),
FieldPanel("body"),
]
@ -172,13 +177,13 @@ class BaseListingPage(RoutablePageMixin, BaseContentPage):
content_panels = [
panel
for panel in BaseContentPage.content_panels
if panel.field_name != "subtitle"
if getattr(panel, "field_name", None) != "subtitle"
]
search_fields = [
panel
for panel in BaseContentPage.search_fields
if panel.field_name != "subtitle"
if getattr(panel, "field_name", None) != "subtitle"
]
class Meta:

View file

@ -27,8 +27,12 @@ class SpotifyPlaylistPage(BaseContentPage):
content_panels = [
panel
for panel in BaseContentPage.content_panels
if panel.field_name != "subtitle"
] + [FieldPanel("spotify_playlist_id")]
if getattr(panel, "field_name", None) != "subtitle"
]
settings_panels = BaseContentPage.settings_panels + [
FieldPanel("spotify_playlist_id")
]
search_fields = [
panel