Skip to content

Commit

Permalink
chore!: Upgrade wagtail to 5.2.1(latest) (#1472)
Browse files Browse the repository at this point in the history
* chore: Upgrade wagtail to 5.2.1(latest)

* disable pylint

* disable pylint with pytest

* fix tests

* fix configure_cms

* remove unused imports

* update caniuse-lite
  • Loading branch information
asadali145 authored Jan 10, 2024
1 parent d1d7f4b commit 5f7266d
Show file tree
Hide file tree
Showing 39 changed files with 759 additions and 325 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ jobs:
- name: Install dependencies
run: poetry install --no-interaction

- name: Lint
run: poetry run pylint ./**/*.py
# TODO: Update Pylint or Integrate ruff
# - name: Lint
# run: poetry run pylint ./**/*.py

# Configurations required for elasticsearch.
- name: Configure sysctl limits
Expand Down
4 changes: 2 additions & 2 deletions applications/migrations/0012_applicantletter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.db import migrations, models
import django.db.models.deletion
import uuid
import wagtail.core.fields
import wagtail.fields


class Migration(migrations.Migration):
Expand All @@ -29,7 +29,7 @@ class Migration(migrations.Migration):
("updated_on", models.DateTimeField(auto_now=True)),
("is_acceptance", models.BooleanField()),
("letter_subject", models.TextField()),
("letter_text", wagtail.core.fields.RichTextField()),
("letter_text", wagtail.fields.RichTextField()),
("hash", models.UUIDField(default=uuid.uuid4, unique=True)),
(
"application",
Expand Down
2 changes: 1 addition & 1 deletion applications/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from django.contrib.auth.models import User
from django.urls import reverse
from django_fsm import FSMField, transition, RETURN_VALUE
from wagtail.core.fields import RichTextField
from wagtail.fields import RichTextField
from mitol.common.utils import now_in_utc
from mitol.common.models import TimestampedModel

Expand Down
4 changes: 2 additions & 2 deletions cms/blocks.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""
Wagtail custom blocks for the CMS
"""
from wagtail.core import blocks
from wagtail import blocks
from wagtail.images.blocks import ImageChooserBlock
from wagtail.core.blocks import StructValue
from wagtail.blocks import StructValue


class ResourceBlock(blocks.StructBlock):
Expand Down
36 changes: 21 additions & 15 deletions cms/factories.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
"""Wagtail page factories"""

import factory
from factory.django import DjangoModelFactory
import faker
import pytz
from wagtail.core.models import Site
from wagtail.core.rich_text import RichText
import wagtail_factories
from factory.django import DjangoModelFactory
from wagtail.models import Site
from wagtail.rich_text import RichText

from cms import models
from cms.blocks import (
TitleLinksBlock,
TitleDescriptionBlock,
CatalogSectionBootcampBlock,
ThreeColumnImageTextBlock,
InstructorSectionBlock,
InstructorBlock,
InstructorSectionBlock,
SponsorSectionBlock,
ThreeColumnImageTextBlock,
TitleDescriptionBlock,
TitleLinksBlock,
)
from klasses.factories import BootcampRunFactory


FAKE = faker.Factory.create()


Expand Down Expand Up @@ -122,7 +121,7 @@ class InstructorBlockFactory(wagtail_factories.StructBlockFactory):
"""InstructorBlockFactory factory class"""

name = factory.fuzzy.FuzzyText(prefix="Name ")
image = factory.SubFactory(wagtail_factories.ImageFactory)
image = factory.SubFactory(wagtail_factories.ImageChooserBlockFactory)
title = factory.fuzzy.FuzzyText(prefix="Title ")

class Meta:
Expand Down Expand Up @@ -271,10 +270,10 @@ class Meta:
class InstructorSectionFactory(wagtail_factories.PageFactory):
"""InstructorSectionFactory factory class"""

banner_image = factory.SubFactory(wagtail_factories.ImageFactory)
banner_image = factory.SubFactory(wagtail_factories.ImageChooserBlockFactory)
heading = factory.fuzzy.FuzzyText(prefix="heading ")
sections = wagtail_factories.StreamFieldFactory(
{"section": InstructorSectionBlockFactory}
{"section": factory.SubFactory(InstructorSectionBlockFactory)}
)

class Meta:
Expand All @@ -284,10 +283,10 @@ class Meta:
class SponsorSectionFactory(wagtail_factories.PageFactory):
"""SponsorSectionFactory factory class"""

banner_image = factory.SubFactory(wagtail_factories.ImageFactory)
banner_image = factory.SubFactory(wagtail_factories.ImageChooserBlockFactory)
heading = factory.fuzzy.FuzzyText(prefix="heading ")
sections = wagtail_factories.StreamFieldFactory(
{"section": InstructorSectionBlockFactory}
{"section": factory.SubFactory(InstructorSectionBlockFactory)}
)

class Meta:
Expand Down Expand Up @@ -326,7 +325,7 @@ class SignatoryPageFactory(wagtail_factories.PageFactory):
title_1 = factory.fuzzy.FuzzyText(prefix="Title_1")
title_2 = factory.fuzzy.FuzzyText(prefix="Title_2")
organization = factory.fuzzy.FuzzyText(prefix="Organization")
signature_image = factory.SubFactory(wagtail_factories.ImageFactory)
signature_image = factory.SubFactory(wagtail_factories.ImageChooserBlockFactory)

class Meta:
model = models.SignatoryPage
Expand All @@ -341,14 +340,21 @@ class Meta:
model = models.CertificateIndexPage


class SignatoryChooserBlockFactory(wagtail_factories.PageChooserBlockFactory):
"""SignatoryPage Chooser block factory."""

class Meta:
model = models.SignatoryPage


class CertificatePageFactory(wagtail_factories.PageFactory):
"""CertificatePage factory class"""

bootcamp_run_name = factory.fuzzy.FuzzyText(prefix="bootcamp_run_")
certificate_name = factory.fuzzy.FuzzyText()
location = factory.fuzzy.FuzzyText()
signatories = wagtail_factories.StreamFieldFactory(
{"signatory": SignatoryPageFactory}
{"signatory": factory.SubFactory(SignatoryChooserBlockFactory)}
)

class Meta:
Expand Down
8 changes: 3 additions & 5 deletions cms/management/commands/configure_cms.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""Setup all CMS related stuff (home page, catalog etc.)"""
import json

from django.conf import settings
from django.contrib.contenttypes.models import ContentType
from django.core.management.base import BaseCommand
from django.utils.text import slugify
from wagtail.core.blocks import StreamValue
from wagtail.core.models import Site, Page
from wagtail.models import Site, Page

from cms.models import HomePage, ResourcePage, ResourcePagesSettings, LetterTemplatePage

Expand All @@ -26,8 +26,7 @@ def create_resource_page_under_parent(title, parent):
resource = ResourcePage(
slug=slugify(title),
title=title,
content=StreamValue(
"content",
content=json.dumps(
[
{
"type": "content",
Expand All @@ -37,7 +36,6 @@ def create_resource_page_under_parent(title, parent):
},
}
],
is_lazy=True,
),
)
parent.add_child(instance=resource)
Expand Down
10 changes: 5 additions & 5 deletions cms/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from django.db import migrations, models
import django.db.models.deletion
import wagtail.core.blocks
import wagtail.core.fields
import wagtail.blocks
import wagtail.fields


class Migration(migrations.Migration):
Expand Down Expand Up @@ -32,15 +32,15 @@ class Migration(migrations.Migration):
),
(
"description",
wagtail.core.fields.RichTextField(
wagtail.fields.RichTextField(
blank=True,
help_text="The description shown on the product page",
),
),
(
"content",
wagtail.core.fields.StreamField(
[("rich_text", wagtail.core.blocks.RichTextBlock())],
wagtail.fields.StreamField(
[("rich_text", wagtail.blocks.RichTextBlock())],
blank=True,
help_text="The content of the benefits page",
),
Expand Down
14 changes: 6 additions & 8 deletions cms/migrations/0002_resourcepage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from django.db import migrations, models
import django.db.models.deletion
import wagtail.core.blocks
import wagtail.core.fields
import wagtail.blocks
import wagtail.fields


class Migration(migrations.Migration):
Expand Down Expand Up @@ -39,19 +39,17 @@ class Migration(migrations.Migration):
),
(
"content",
wagtail.core.fields.StreamField(
wagtail.fields.StreamField(
[
(
"content",
wagtail.core.blocks.StructBlock(
wagtail.blocks.StructBlock(
[
(
"heading",
wagtail.core.blocks.CharBlock(
max_length=100
),
wagtail.blocks.CharBlock(max_length=100),
),
("detail", wagtail.core.blocks.RichTextBlock()),
("detail", wagtail.blocks.RichTextBlock()),
]
),
)
Expand Down
10 changes: 5 additions & 5 deletions cms/migrations/0003_bootcamp_product_run_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from django.db import migrations, models
import django.db.models.deletion
import wagtail.core.blocks
import wagtail.core.fields
import wagtail.blocks
import wagtail.fields


class Migration(migrations.Migration):
Expand Down Expand Up @@ -34,15 +34,15 @@ class Migration(migrations.Migration):
),
(
"description",
wagtail.core.fields.RichTextField(
wagtail.fields.RichTextField(
blank=True,
help_text="The description shown on the product page",
),
),
(
"content",
wagtail.core.fields.StreamField(
[("rich_text", wagtail.core.blocks.RichTextBlock())],
wagtail.fields.StreamField(
[("rich_text", wagtail.blocks.RichTextBlock())],
blank=True,
help_text="The content of the benefits page",
),
Expand Down
4 changes: 2 additions & 2 deletions cms/migrations/0005_product_page_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from django.db import migrations, models
import django.db.models.deletion
import wagtail.core.fields
import wagtail.fields


class Migration(migrations.Migration):
Expand Down Expand Up @@ -38,7 +38,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name="bootcamprunpage",
name="description",
field=wagtail.core.fields.RichTextField(
field=wagtail.fields.RichTextField(
blank=True, help_text="The description shown on the page."
),
),
Expand Down
20 changes: 10 additions & 10 deletions cms/migrations/0007_instructorspage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from django.db import migrations, models
import django.db.models.deletion
import wagtail.core.blocks
import wagtail.core.fields
import wagtail.blocks
import wagtail.fields
import wagtail.images.blocks


Expand Down Expand Up @@ -31,37 +31,37 @@ class Migration(migrations.Migration):
),
(
"sections",
wagtail.core.fields.StreamField(
wagtail.fields.StreamField(
[
(
"section",
wagtail.core.blocks.StructBlock(
wagtail.blocks.StructBlock(
[
(
"heading",
wagtail.core.blocks.CharBlock(
wagtail.blocks.CharBlock(
help_text="The heading to display for this section on the page.",
max_length=255,
),
),
(
"subhead",
wagtail.core.blocks.CharBlock(
wagtail.blocks.CharBlock(
help_text="The subhead to display for this section on the page.",
max_length=255,
),
),
(
"members",
wagtail.core.blocks.StreamBlock(
wagtail.blocks.StreamBlock(
[
(
"member",
wagtail.core.blocks.StructBlock(
wagtail.blocks.StructBlock(
[
(
"name",
wagtail.core.blocks.CharBlock(
wagtail.blocks.CharBlock(
help_text="Name of the instructor.",
max_length=100,
),
Expand All @@ -74,7 +74,7 @@ class Migration(migrations.Migration):
),
(
"title",
wagtail.core.blocks.CharBlock(
wagtail.blocks.CharBlock(
help_text="A brief description about the instructor.",
max_length=255,
),
Expand Down
Loading

0 comments on commit 5f7266d

Please sign in to comment.