From 27bce00c46fd40e42775a13e58b0b0c5d2de5e84 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sat, 27 Aug 2022 19:21:51 +0100 Subject: [PATCH] Remove subtitle from listing pages --- website/blog/factories.py | 4 +-- ...ostcollectionlistpage_subtitle_and_more.py | 33 +++++++++++++++++++ website/common/factories.py | 6 +++- .../0020_remove_listingpage_subtitle.py | 17 ++++++++++ website/common/models.py | 13 ++++++++ 5 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 website/blog/migrations/0021_remove_blogpostcollectionlistpage_subtitle_and_more.py create mode 100644 website/common/migrations/0020_remove_listingpage_subtitle.py diff --git a/website/blog/factories.py b/website/blog/factories.py index fae59d9..c1f4b7e 100644 --- a/website/blog/factories.py +++ b/website/blog/factories.py @@ -1,9 +1,9 @@ -from website.common.factories import BaseContentFactory +from website.common.factories import BaseContentFactory, BaseListingFactory from . import models -class BlogPostListPageFactory(BaseContentFactory): +class BlogPostListPageFactory(BaseListingFactory): class Meta: model = models.BlogPostListPage diff --git a/website/blog/migrations/0021_remove_blogpostcollectionlistpage_subtitle_and_more.py b/website/blog/migrations/0021_remove_blogpostcollectionlistpage_subtitle_and_more.py new file mode 100644 index 0000000..e254244 --- /dev/null +++ b/website/blog/migrations/0021_remove_blogpostcollectionlistpage_subtitle_and_more.py @@ -0,0 +1,33 @@ +# Generated by Django 4.0.6 on 2022-08-27 18:16 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("blog", "0020_alter_blogpostcollectionlistpage_body_and_more"), + ] + + operations = [ + migrations.RemoveField( + model_name="blogpostcollectionlistpage", + name="subtitle", + ), + migrations.RemoveField( + model_name="blogpostcollectionpage", + name="subtitle", + ), + migrations.RemoveField( + model_name="blogpostlistpage", + name="subtitle", + ), + migrations.RemoveField( + model_name="blogposttaglistpage", + name="subtitle", + ), + migrations.RemoveField( + model_name="blogposttagpage", + name="subtitle", + ), + ] diff --git a/website/common/factories.py b/website/common/factories.py index 3879417..9d4b381 100644 --- a/website/common/factories.py +++ b/website/common/factories.py @@ -9,11 +9,15 @@ class BaseContentFactory(wagtail_factories.PageFactory): subtitle = factory.Faker("bs") +class BaseListingFactory(wagtail_factories.PageFactory): + title = factory.Faker("catch_phrase") + + class ContentPageFactory(BaseContentFactory): class Meta: model = models.ContentPage -class ListingPageFactory(BaseContentFactory): +class ListingPageFactory(BaseListingFactory): class Meta: model = models.ListingPage diff --git a/website/common/migrations/0020_remove_listingpage_subtitle.py b/website/common/migrations/0020_remove_listingpage_subtitle.py new file mode 100644 index 0000000..63b4102 --- /dev/null +++ b/website/common/migrations/0020_remove_listingpage_subtitle.py @@ -0,0 +1,17 @@ +# Generated by Django 4.0.6 on 2022-08-27 18:16 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("common", "0019_alter_contentpage_body_alter_listingpage_body"), + ] + + operations = [ + migrations.RemoveField( + model_name="listingpage", + name="subtitle", + ), + ] diff --git a/website/common/models.py b/website/common/models.py index 18d4813..cd3561b 100644 --- a/website/common/models.py +++ b/website/common/models.py @@ -178,6 +178,19 @@ class ContentPage(BaseContentPage): class BaseListingPage(RoutablePageMixin, BaseContentPage): PAGE_SIZE = 20 + subtitle = None + + content_panels = [ + panel + for panel in BaseContentPage.content_panels + if panel.field_name != "subtitle" + ] + + search_fields = [ + panel + for panel in BaseContentPage.search_fields + if panel.field_name != "subtitle" + ] class Meta: abstract = True