Skip to content

Commit

Permalink
Merge pull request #8366 from cfpb/wagtail6
Browse files Browse the repository at this point in the history
Upgrade to Wagtail 6.0
  • Loading branch information
willbarton committed May 6, 2024
2 parents 61d34e2 + a6b0e85 commit 2e721b5
Show file tree
Hide file tree
Showing 23 changed files with 54 additions and 45 deletions.
3 changes: 0 additions & 3 deletions cfgov/ask_cfpb/models/answer_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ class AnswerPage(CFGOVPage):
ask_blocks.AskAnswerContent(),
blank=True,
verbose_name="Answer",
use_json_field=True,
)
answer_base = models.ForeignKey(
Answer,
Expand Down Expand Up @@ -194,7 +193,6 @@ class AnswerPage(CFGOVPage):
],
blank=True,
max_num=1,
use_json_field=True,
)

content_panels = CFGOVPage.content_panels + [
Expand Down Expand Up @@ -251,7 +249,6 @@ class AnswerPage(CFGOVPage):
),
],
blank=True,
use_json_field=True,
)

sidebar_panels = [
Expand Down
2 changes: 0 additions & 2 deletions cfgov/filing_instruction_guide/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ class FIGContentPage(CFGOVPage, ClusterableModel):
)
],
blank=True,
use_json_field=True,
)

content = StreamField(
Expand All @@ -104,7 +103,6 @@ class FIGContentPage(CFGOVPage, ClusterableModel):
("Fig_Subsection", FigSubsection()),
("Fig_Level_3_Subsection", FigLevel3Subsection()),
],
use_json_field=True,
)

# Main content panel
Expand Down
2 changes: 0 additions & 2 deletions cfgov/form_explainer/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@ class FormExplainerPage(CFGOVPage):
("text_introduction", molecules.TextIntroduction()),
],
blank=True,
use_json_field=True,
)

content = StreamField(
FormExplainerContent,
use_json_field=True,
)

# General content tab
Expand Down
1 change: 0 additions & 1 deletion cfgov/mega_menu/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class Menu(PreviewableMixin, models.Model):

submenus = StreamField(
MenuStreamBlock(),
use_json_field=True,
)

class Meta:
Expand Down
2 changes: 0 additions & 2 deletions cfgov/paying_for_college/models/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class CollegeCostsPage(CFGOVPage):
("featured_content", organisms.FeaturedContent()),
],
blank=True,
use_json_field=True,
)

content = StreamField(
Expand All @@ -29,7 +28,6 @@ class CollegeCostsPage(CFGOVPage):
("raw_html_block", blocks.RawHTMLBlock(label="Raw HTML block")),
],
blank=True,
use_json_field=True,
)

content_panels = CFGOVPage.content_panels + [
Expand Down
4 changes: 0 additions & 4 deletions cfgov/regulations3k/models/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,13 @@ class RegulationLandingPage(ShareableRoutablePageMixin, CFGOVPage):
("hero", molecules.Hero()),
],
blank=True,
use_json_field=True,
)
content = StreamField(
[
("notification", molecules.Notification()),
("full_width_text", RegulationsListingFullWidthText()),
],
blank=True,
use_json_field=True,
)

# General content tab
Expand Down Expand Up @@ -236,7 +234,6 @@ class RegulationPage(ShareableRoutablePageMixin, CFGOVPage):
("notification", molecules.Notification()),
],
blank=True,
use_json_field=True,
)

# notification
Expand All @@ -248,7 +245,6 @@ class RegulationPage(ShareableRoutablePageMixin, CFGOVPage):
],
null=True,
blank=True,
use_json_field=True,
)

regulation = models.ForeignKey(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ class ActivityIndexPage(CFGOVPage):
("notification", molecules.Notification()),
],
blank=True,
use_json_field=True,
)

results = {}
Expand Down
43 changes: 43 additions & 0 deletions cfgov/v1/migrations/0033_wagtailsearch_querydailyhits_index_fix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Generated by Django 4.2.11 on 2024-04-29 12:46

from django.db import migrations

# This is a one-off fix to convert an existing unique index on a Wagtail
# table into a unique constraint. See internal Design-and-Content-Team#389
# for a description of the problem with a different constraint,
# https://github.com/cfpb/consumerfinance.gov/pull/8066 for the fix this is
# based on.
#
# The mode QueryDailyHits is and its `UNIQUE` constraints are removed in
# wagtail.search.migrations.0008_remove_query_and_querydailyhits_models.py
# in Wagtail 6.0. This migration will prepare our database for the constraint's
# constraint's removal.

table_name = "wagtailsearch_querydailyhits"
index_name = "idx_17496_wagtailsearch_querydailyhits_query_id_4e12c633921cb0c"
unique_together = "query_id, date"

# nosec used here to suppress Bandit warning about this raw SQL.
# https://bandit.readthedocs.io/en/latest/plugins/b608_hardcoded_sql_expressions.html
sql = f"""
DO $$ BEGIN
IF EXISTS (SELECT FROM pg_indexes WHERE indexname='{index_name}') THEN
DROP INDEX {index_name};
ALTER TABLE {table_name} ADD CONSTRAINT {index_name} UNIQUE({unique_together});
END IF;
END $$;
""".strip() # nosec B608


class Migration(migrations.Migration):
dependencies = [
("v1", "0032_alter_browsepage_content"),
]

run_before = [
("wagtailsearch", "0008_remove_query_and_querydailyhits_models"),
]

operations = [
migrations.RunSQL(sql, migrations.RunSQL.noop, elidable=True)
]
1 change: 0 additions & 1 deletion cfgov/v1/models/banners.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class Banner(models.Model):
[("content", Notification())],
min_num=1,
max_num=1,
use_json_field=True,
)

enabled = models.BooleanField()
Expand Down
1 change: 0 additions & 1 deletion cfgov/v1/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ class CFGOVPage(Page):
),
],
blank=True,
use_json_field=True,
)

# Panels
Expand Down
2 changes: 0 additions & 2 deletions cfgov/v1/models/blog_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class BlogContent(blocks.StreamBlock):
class BlogPage(AbstractFilterPage):
content = StreamField(
BlogContent,
use_json_field=True,
)

edit_handler = AbstractFilterPage.generate_edit_handler(
Expand Down Expand Up @@ -51,7 +50,6 @@ class LegacyBlogContent(BlogContent):
class LegacyBlogPage(AbstractFilterPage):
content = StreamField(
LegacyBlogContent,
use_json_field=True,
)

edit_handler = AbstractFilterPage.generate_edit_handler(
Expand Down
2 changes: 0 additions & 2 deletions cfgov/v1/models/browse_filterable_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@ class BrowseFilterablePage(AbstractFilterablePage, AbstractBrowsePage):
("text_introduction", molecules.TextIntroduction()),
("featured_content", organisms.FeaturedContent()),
],
use_json_field=True,
)
content = StreamField(
BrowseFilterableContent,
blank=True,
use_json_field=True,
)

# General content tab
Expand Down
2 changes: 0 additions & 2 deletions cfgov/v1/models/browse_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ class BrowsePage(AbstractBrowsePage):
("notification", molecules.Notification()),
],
blank=True,
use_json_field=True,
)

share_and_print = models.BooleanField(
Expand Down Expand Up @@ -140,7 +139,6 @@ class BrowsePage(AbstractBrowsePage):
("faq_group", schema.FAQGroup()),
],
blank=True,
use_json_field=True,
)

# General content tab
Expand Down
1 change: 0 additions & 1 deletion cfgov/v1/models/enforcement_action_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ class EnforcementActionPage(AbstractFilterPage):
("notification", molecules.Notification()),
],
blank=True,
use_json_field=True,
)

content_panels = [FieldPanel("header"), FieldPanel("content")]
Expand Down
2 changes: 0 additions & 2 deletions cfgov/v1/models/landing_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class LandingPage(CFGOVPage):
("text_introduction", molecules.TextIntroduction()),
],
blank=True,
use_json_field=True,
)

content = StreamField(
Expand All @@ -22,7 +21,6 @@ class LandingPage(CFGOVPage):
("feature_cards", organisms.FeatureCards()),
],
blank=True,
use_json_field=True,
)

# General content tab
Expand Down
7 changes: 2 additions & 5 deletions cfgov/v1/models/learn_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class AbstractFilterPage(CFGOVPage):
("notification", molecules.Notification()),
],
blank=True,
use_json_field=True,
)
date_published = models.DateField(default=date.today)

Expand Down Expand Up @@ -101,7 +100,6 @@ class LearnPage(AbstractFilterPage):
("contact_us_table", organisms.ContactUsTable()),
],
blank=True,
use_json_field=True,
)

edit_handler = AbstractFilterPage.generate_edit_handler(
Expand All @@ -125,7 +123,6 @@ class DocumentDetailPage(AbstractFilterPage):
("case_docket_table", organisms.CaseDocketTable()),
],
blank=True,
use_json_field=True,
block_counts={"case_docket_table": {"max_num": 1}},
)
edit_handler = AbstractFilterPage.generate_edit_handler(
Expand Down Expand Up @@ -173,7 +170,6 @@ class EventPage(AbstractFilterPage):
),
],
blank=True,
use_json_field=True,
)
start_dt = models.DateTimeField("Start")
end_dt = models.DateTimeField("End", blank=True, null=True)
Expand Down Expand Up @@ -271,7 +267,8 @@ class EventPage(AbstractFilterPage):

# Agenda content fields
agenda_items = StreamField(
[("item", AgendaItemBlock())], blank=True, use_json_field=True
[("item", AgendaItemBlock())],
blank=True,
)

# General content tab
Expand Down
2 changes: 0 additions & 2 deletions cfgov/v1/models/snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class Contact(models.Model):
("hyperlink", molecules.ContactHyperlink()),
],
blank=True,
use_json_field=True,
)

panels = [
Expand Down Expand Up @@ -154,7 +153,6 @@ class ReusableNotification(RevisionMixin, models.Model):
[("content", Notification())],
min_num=1,
max_num=1,
use_json_field=True,
)

def __str__(self):
Expand Down
4 changes: 2 additions & 2 deletions cfgov/v1/models/story_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class StoryContent(StreamBlock):


class StoryPage(CFGOVPage):
header = StreamField(StoryHeader, blank=True, use_json_field=True)
content = StreamField(StoryContent, blank=True, use_json_field=True)
header = StreamField(StoryHeader, blank=True)
content = StreamField(StoryContent, blank=True)

content_panels = CFGOVPage.content_panels + [
FieldPanel("header"),
Expand Down
4 changes: 2 additions & 2 deletions cfgov/v1/models/sublanding_filterable_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ class SublandingFilterablePage(AbstractFilterablePage, CFGOVPage):
("hero", molecules.Hero()),
],
blank=True,
use_json_field=True,
)
content = StreamField(
SublandingFilterableContent, blank=True, use_json_field=True
SublandingFilterableContent,
blank=True,
)

# General content tab
Expand Down
3 changes: 0 additions & 3 deletions cfgov/v1/models/sublanding_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class SublandingPage(CFGOVPage):
("hero", molecules.Hero()),
],
blank=True,
use_json_field=True,
)
content = StreamField(
[
Expand All @@ -42,7 +41,6 @@ class SublandingPage(CFGOVPage):
("expandable", organisms.Expandable()),
],
blank=True,
use_json_field=True,
)
sidebar_breakout = StreamField(
[
Expand Down Expand Up @@ -85,7 +83,6 @@ class SublandingPage(CFGOVPage):
("job_listing_list", JobListingList()),
],
blank=True,
use_json_field=True,
)

# General content tab
Expand Down
4 changes: 2 additions & 2 deletions requirements/libraries.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ tailslide==0.1.1
wagtail-autocomplete==0.11.0
wagtail-content-audit==0.1
wagtail_draftail_anchors==0.6.0
wagtail-flags==5.3.0
wagtail-flags==5.3.1
wagtail-inventory==2.6
wagtail-placeholder-images==0.1.1
wagtail-sharing==2.12.1
wagtail-treemodeladmin==1.9.0
wagtail-treemodeladmin==1.9.2
wagtailmedia==0.15.1

# These packages are installed from GitHub.
Expand Down
2 changes: 1 addition & 1 deletion requirements/wagtail.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
wagtail==5.2.3
wagtail==6.0.2
4 changes: 2 additions & 2 deletions test/cypress/integration/admin/admin-helpers.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class AdminPage {
}

getImages() {
return cy.get('#image-results').find('li');
return cy.get('#listing-results').find('li');
}

tags() {
Expand All @@ -47,7 +47,7 @@ export class AdminPage {
}

getFirstDocument() {
return cy.get('#document-results').find('tr').eq(1);
return cy.get('#listing-results').find('tr').eq(1);
}

openContacts() {
Expand Down

0 comments on commit 2e721b5

Please sign in to comment.