Skip to content

Commit

Permalink
feat: How you will learn and B2B section added for external courses
Browse files Browse the repository at this point in the history
  • Loading branch information
marslanabdulrauf committed Nov 19, 2024
1 parent eda16ee commit f508324
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 0 deletions.
67 changes: 67 additions & 0 deletions cms/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,73 @@
FORMAT_HYBRID = "Hybrid"
FORMAT_OTHER = "Other"

HOW_YOU_WILL_LEARN_SECTION = {
"title": "HOW YOU WILL LEARN",
"technique_items": [
{
"type": "techniques",
"value": {
"heading": "LEARN BY DOING",
"sub_heading": "Practice processes and methods through simulations, assessments, case studies, and tools.",
"image": "static/images/how_you_will_learn/idea.png",
},
},
{
"type": "techniques",
"value": {
"heading": "LEARN FROM OTHERS",
"sub_heading": "Connect with an international community of professionals while working on projects based on real-world examples.",
"image": "static/images/how_you_will_learn/network.png",
},
},
{
"type": "techniques",
"value": {
"heading": "LEARN ON DEMAND",
"sub_heading": "Access all of the content online and watch videos on the go.",
"image": "static/images/how_you_will_learn/work-balance.png",
},
},
{
"type": "techniques",
"value": {
"heading": "REFLECT AND APPLY",
"sub_heading": "Bring your new skills to your organization, through examples from technical work environments and ample prompts for reflection.",
"image": "static/images/how_you_will_learn/feedback.png",
},
},
{
"type": "techniques",
"value": {
"heading": "DEMONSTRATE YOUR SUCCESS",
"sub_heading": "Earn a Professional Certificate and CEUs from MIT xPRO.",
"image": "static/images/how_you_will_learn/certificate.png",
},
},
{
"type": "techniques",
"value": {
"heading": "LEARN FROM THE BEST",
"sub_heading": "Gain insights from leading MIT faculty and industry experts.",
"image": "static/images/how_you_will_learn/trend-speaker.png",
},
},
],
}

B2B_SECTION = {
"title": "THE BEST COMPANIES CONNECT WITH THE BEST MINDS AT MIT",
"content": """
<p>Deepen your team's career knowledge and expand their abilities with MIT xPRO's online courses for professionals. Develop customized learning for your team with bespoke courses and programs on your schedule. Set a standard of knowledge and skills, leading to effective communication among employees and consistency across the enterprise.</p>
<p>Find out what MIT xPRO can do for your team.</p>
""",
"action_title": "INQUIRE NOW",
"action_url": "https://learn-xpro.mit.edu/for-teams#b2bform",
"image": "static/images/enterprise/enterprise-colab.jpg",
}


class CatalogSorting(enum.Enum):
"""Catalog sorting option"""
Expand Down
18 changes: 18 additions & 0 deletions cms/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
CatalogSorting,
)
from cms.forms import CertificatePageForm, CoursewareForm
from cms.utils import create_b2b_section, create_how_you_will_learn_section
from courses.constants import DEFAULT_COURSE_IMG_PATH, PROGRAM_RUN_ID_PATTERN
from courses.models import (
Course,
Expand Down Expand Up @@ -1487,6 +1488,23 @@ class ExternalCoursePage(CourseProductPage):

template = "product_page.html"

def save(self, *args, **kwargs):
if not self.id:
super().save(*args, **kwargs)
return

icongrid_page = self.get_child_page_of_type_including_draft(
LearningTechniquesPage
)
if not icongrid_page:
icongrid_page = create_how_you_will_learn_section()
self.add_child(instance=icongrid_page)

b2b_page = self.get_child_page_of_type_including_draft(ForTeamsPage)
if not b2b_page:
b2b_page = create_b2b_section()
self.add_child(instance=b2b_page)


class ExternalProgramPage(ProgramProductPage):
"""
Expand Down
36 changes: 36 additions & 0 deletions cms/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from pathlib import Path

from django.core.files import File
from wagtail.images.models import Image

from cms.constants import B2B_SECTION, HOW_YOU_WILL_LEARN_SECTION


def create_how_you_will_learn_section():
from cms.models import LearningTechniquesPage

section_content = HOW_YOU_WILL_LEARN_SECTION.copy()
for technique in section_content["technique_items"]:
image_title = technique["value"]["heading"]
with Path(technique["value"]["image"]).open("rb") as img:
img_file = File(img)
image, _ = Image.objects.get_or_create(
title=image_title, defaults={"file": img_file}
)
technique["value"]["image"] = image.id

return LearningTechniquesPage(**section_content)


def create_b2b_section():
from cms.models import ForTeamsPage

section_content = B2B_SECTION.copy()
with Path(section_content["image"]).open("rb") as img:
img_file = File(img)
image, _ = Image.objects.get_or_create(
title=section_content["title"], defaults={"file": img_file}
)
section_content["image"] = image

return ForTeamsPage(**section_content)
Binary file added static/images/enterprise/enterprise-colab.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/images/how_you_will_learn/certificate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/images/how_you_will_learn/feedback.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/images/how_you_will_learn/idea.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/images/how_you_will_learn/network.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/images/how_you_will_learn/work-balance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f508324

Please sign in to comment.