From bccc94899533513d5af5182db5e9ddd5c7ca410b Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 21 Sep 2022 13:30:06 +0100 Subject: [PATCH] Restructure fields in editor pages Move as much as possible out of the "Content" tab, so that's just about the actual content --- website/blog/models.py | 2 +- website/common/models.py | 15 ++++++++++----- website/spotify/models.py | 8 ++++++-- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/website/blog/models.py b/website/blog/models.py index e4f23a8..9b41660 100644 --- a/website/blog/models.py +++ b/website/blog/models.py @@ -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"), ] diff --git a/website/common/models.py b/website/common/models.py index 2df3c26..0040360 100644 --- a/website/common/models.py +++ b/website/common/models.py @@ -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: diff --git a/website/spotify/models.py b/website/spotify/models.py index 2efe778..39117d0 100644 --- a/website/spotify/models.py +++ b/website/spotify/models.py @@ -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