Skip to content

Commit

Permalink
feat: enterprise page (#2834)
Browse files Browse the repository at this point in the history
* feat: enterprise page

* fix: enterprise page tests

* fix: richtext fields

* fix: migration file

* fix: code formatting

* fix: cta description gap

* fix: nav border line

* fix: update richtext field tags and styles

* fix: learning journey background

* fix: update banner background design structure

* fix: addressed review feedback

* fix: updated migrations file

* fix: code formatting

* fix: failed tests

* fix: enterprise page slug

* fix: update configure_wagtail command for enterprise page

* fix: configure_wagtail command comments
  • Loading branch information
shahbaz-shabbir05 authored Jan 19, 2024
1 parent 9cc39a1 commit 8373791
Show file tree
Hide file tree
Showing 32 changed files with 2,294 additions and 6 deletions.
4 changes: 4 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@
"description": "Form ID for Hubspot Forms API",
"required": false
},
"HUBSPOT_ENTERPRISE_PAGE_FORM_ID": {
"description": "Form ID for Hubspot for Enterprise Page",
"required": false
},
"HUBSPOT_FOOTER_FORM_GUID": {
"description": "Form guid over hub spot for footer block.",
"required": false
Expand Down
34 changes: 33 additions & 1 deletion cms/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.contrib.contenttypes.models import ContentType
from wagtail.models import Page, Site
from cms import models as cms_models
from cms.constants import CERTIFICATE_INDEX_SLUG
from cms.constants import CERTIFICATE_INDEX_SLUG, ENTERPRISE_PAGE_SLUG


log = logging.getLogger(__name__)
Expand Down Expand Up @@ -201,6 +201,37 @@ def ensure_index_pages(): # pylint: disable=too-many-branches
home_page.add_child(instance=blog_index)


def ensure_enterprise_page():
"""
Ensures that an enterprise page with the correct slug exists.
"""
enterprise_page = cms_models.EnterprisePage.objects.first()

if enterprise_page and enterprise_page.slug == ENTERPRISE_PAGE_SLUG:
return

enterprise_page_data = {
"title": "Enterprise Page",
"slug": ENTERPRISE_PAGE_SLUG,
"description": "Deepen your team’s career knowledge and expand their abilities with MIT xPRO’s online "
"courses for professionals.",
"action_title": "Find out what MIT xPRO can do for your team.",
"headings": [
{
"type": "heading",
"value": {
"upper_head": "THE BEST COMPANIES",
"middle_head": "CONNECT WITH",
"bottom_head": "THE BEST MINDS AT MIT",
},
},
],
}
enterprise_page = cms_models.EnterprisePage(**enterprise_page_data)
home_page = get_home_page()
home_page.add_child(instance=enterprise_page)


def configure_wagtail():
"""
Ensures that all appropriate changes have been made to Wagtail that will
Expand All @@ -209,3 +240,4 @@ def configure_wagtail():
ensure_home_page_and_site()
ensure_catalog_page()
ensure_index_pages()
ensure_enterprise_page()
42 changes: 42 additions & 0 deletions cms/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,48 @@ class CourseRunCertificateOverrides(blocks.StructBlock):
)


class BannerHeadingBlock(blocks.StructBlock):
"""
A custom block designed for creating banner headings on an enterprise page.
"""

upper_head = blocks.CharBlock(max_length=25, help_text="The main heading.")
middle_head = blocks.CharBlock(max_length=25, help_text="Secondary heading.")
bottom_head = blocks.CharBlock(max_length=25, help_text="Lower heading.")

class Meta:
icon = "title"
label = "Banner Headings"


class SuccessStoriesBlock(blocks.StructBlock):
"""
A custom block designed to represent an individual success story.
"""

title = blocks.CharBlock(
max_length=255, help_text="Enter the title of the success story."
)
image = ImageChooserBlock(
help_text="Select an image to accompany the success story.",
)
content = blocks.TextBlock(
help_text="Provide the detailed content or description of the success story."
)
call_to_action = blocks.CharBlock(
max_length=100,
default="Read More",
help_text="Enter the text for the call-to-action button (e.g., 'Read More').",
)
action_url = blocks.URLBlock(
help_text="Provide the URL that the call-to-action button should link to.",
)

class Meta:
icon = "tick-inverse"
label = "Success Story"


def validate_unique_readable_ids(value):
"""
Validates that all of the course run override blocks in this stream field have
Expand Down
1 change: 1 addition & 0 deletions cms/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
CERTIFICATE_INDEX_SLUG = "certificate"
WEBINAR_INDEX_SLUG = "webinars"
BLOG_INDEX_SLUG = "blog"
ENTERPRISE_PAGE_SLUG = "enterprise"

ALL_TOPICS = "All Topics"
ALL_TAB = "all-tab"
Expand Down
76 changes: 76 additions & 0 deletions cms/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@
FacultyBlock,
LearningTechniqueBlock,
ResourceBlock,
SuccessStoriesBlock,
UserTestimonialBlock,
)
from cms.constants import UPCOMING_WEBINAR
from cms.models import (
BlogIndexPage,
CatalogPage,
CertificatePage,
CompaniesLogoCarouselSection,
CourseIndexPage,
CoursePage,
CoursesInProgramPage,
EnterprisePage,
ExternalCoursePage,
ExternalProgramPage,
FacultyMembersPage,
Expand All @@ -29,7 +32,9 @@
FrequentlyAskedQuestionPage,
HomePage,
ImageCarouselPage,
LearningJourneySection,
LearningOutcomesPage,
LearningStrategyFormSection,
LearningTechniquesPage,
NewsAndEventsBlock,
NewsAndEventsPage,
Expand All @@ -38,6 +43,7 @@
ResourcePage,
SignatoryPage,
SiteNotification,
SuccessStoriesSection,
TextSection,
TextVideoSection,
UserTestimonialsPage,
Expand Down Expand Up @@ -500,3 +506,73 @@ class BlogIndexPageFactory(wagtail_factories.PageFactory):

class Meta:
model = BlogIndexPage


class EnterprisePageFactory(wagtail_factories.PageFactory):
"""EnterprisePage factory"""

class Meta:
model = EnterprisePage


class CompaniesLogoCarouselPageFactory(wagtail_factories.PageFactory):
"""CompaniesLogoCarouselPage factory class"""

heading = factory.fuzzy.FuzzyText(prefix="heading")
images = wagtail_factories.StreamFieldFactory(
{"image": factory.SubFactory(wagtail_factories.ImageChooserBlockFactory)}
)

class Meta:
model = CompaniesLogoCarouselSection


class LearningJourneyPageFactory(wagtail_factories.PageFactory):
"""LearningJourneyPage factory class"""

heading = factory.fuzzy.FuzzyText(prefix="heading ")
description = factory.fuzzy.FuzzyText()
journey_image = factory.SubFactory(wagtail_factories.ImageFactory)
journey_items = factory.SubFactory(wagtail_factories.StreamFieldFactory)
call_to_action = factory.fuzzy.FuzzyText(prefix="call_to_action ")
action_url = factory.Faker("uri")
pdf_file = factory.SubFactory(wagtail_factories.DocumentFactory)

class Meta:
model = LearningJourneySection


class SuccessStoriesBlockFactory(wagtail_factories.StructBlockFactory):
"""SuccessStoriesBlock factory class"""

title = factory.fuzzy.FuzzyText(prefix="title ")
image = factory.SubFactory(wagtail_factories.ImageChooserBlockFactory)
content = factory.fuzzy.FuzzyText(prefix="content ")
call_to_action = factory.fuzzy.FuzzyText(prefix="call_to_action ")
action_url = factory.Faker("uri")

class Meta:
model = SuccessStoriesBlock


class SuccessStoriesPageFactory(wagtail_factories.PageFactory):
"""SuccessStoriesPage factory class"""

heading = factory.fuzzy.FuzzyText(prefix="heading ")
subhead = factory.fuzzy.FuzzyText(prefix="Subhead ")
success_stories = wagtail_factories.StreamFieldFactory(
{"success_story": factory.SubFactory(SuccessStoriesBlockFactory)}
)

class Meta:
model = SuccessStoriesSection


class LearningStrategyFormPageFactory(wagtail_factories.PageFactory):
"""LearningStrategyForm factory class"""

heading = factory.fuzzy.FuzzyText(prefix="heading ")
subhead = factory.fuzzy.FuzzyText(prefix="Subhead ")

class Meta:
model = LearningStrategyFormSection
Loading

0 comments on commit 8373791

Please sign in to comment.