Skip to content

Commit

Permalink
feat: add hybrid format option for courseware page
Browse files Browse the repository at this point in the history
  • Loading branch information
asadali145 committed Aug 21, 2024
1 parent 1ceb478 commit e71f785
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 9 deletions.
1 change: 1 addition & 0 deletions cms/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@
ON_DEMAND_WEBINAR_BUTTON_TITLE = "VIEW RECORDING"

FORMAT_ONLINE = "Online"
FORMAT_HYBRID = "Hybrid"
FORMAT_OTHER = "Other"
68 changes: 68 additions & 0 deletions cms/migrations/0072_add_hybrid_courseware_format_option.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Generated by Django 4.2.15 on 2024-08-21 08:09

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("cms", "0071_alter_certificatepage_signatories"),
]

operations = [
migrations.AlterField(
model_name="coursepage",
name="format",
field=models.CharField(
choices=[
("Online", "Online"),
("Hybrid", "Hybrid"),
("Other", "Other"),
],
default="Online",
help_text="A short description indicating the format of a program or course",
max_length=20,
),
),
migrations.AlterField(
model_name="externalcoursepage",
name="format",
field=models.CharField(
choices=[
("Online", "Online"),
("Hybrid", "Hybrid"),
("Other", "Other"),
],
default="Online",
help_text="A short description indicating the format of a program or course",
max_length=20,
),
),
migrations.AlterField(
model_name="externalprogrampage",
name="format",
field=models.CharField(
choices=[
("Online", "Online"),
("Hybrid", "Hybrid"),
("Other", "Other"),
],
default="Online",
help_text="A short description indicating the format of a program or course",
max_length=20,
),
),
migrations.AlterField(
model_name="programpage",
name="format",
field=models.CharField(
choices=[
("Online", "Online"),
("Hybrid", "Hybrid"),
("Other", "Other"),
],
default="Online",
help_text="A short description indicating the format of a program or course",
max_length=20,
),
),
]
2 changes: 2 additions & 0 deletions cms/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
CERTIFICATE_INDEX_SLUG,
COURSE_INDEX_SLUG,
ENTERPRISE_PAGE_SLUG,
FORMAT_HYBRID,
FORMAT_ONLINE,
FORMAT_OTHER,
ON_DEMAND_WEBINAR,
Expand Down Expand Up @@ -928,6 +929,7 @@ class Meta:
)
FORMAT_CHOICES = [
(FORMAT_ONLINE, FORMAT_ONLINE),
(FORMAT_HYBRID, FORMAT_HYBRID),
(FORMAT_OTHER, FORMAT_OTHER),
]
format = models.CharField(
Expand Down
13 changes: 7 additions & 6 deletions cms/models_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from wagtail.test.utils.form_data import querydict_from_html

from cms.constants import (
FORMAT_HYBRID,
FORMAT_ONLINE,
FORMAT_OTHER,
ON_DEMAND_WEBINAR,
Expand Down Expand Up @@ -881,11 +882,11 @@ def test_course_page_format_field_default_value():
assert course_page.format == FORMAT_ONLINE


@pytest.mark.parametrize("course_format", [FORMAT_ONLINE, FORMAT_OTHER])
@pytest.mark.parametrize("course_format", [FORMAT_ONLINE, FORMAT_HYBRID, FORMAT_OTHER])
def test_course_page_format_field_choices(course_format, staff_user):
"""
Verifies that if the "format" field in a course page contains the values FORMAT_ONLINE and FORMAT_OTHER,
and they are in the same context.
Verifies that if the "format" field in a course page contains the values
FORMAT_ONLINE, FORMAT_HYBRID, and FORMAT_OTHER, and they are in the same context.
"""
course_page = CoursePageFactory.create(format=course_format)

Expand Down Expand Up @@ -961,11 +962,11 @@ def test_program_page_format_field_default_value():
assert program_page.format == FORMAT_ONLINE


@pytest.mark.parametrize("program_format", [FORMAT_ONLINE, FORMAT_OTHER])
@pytest.mark.parametrize("program_format", [FORMAT_ONLINE, FORMAT_HYBRID, FORMAT_OTHER])
def test_program_page_format_field_choices(program_format, staff_user):
"""
Verifies that if the "format" field in a program page contains the values FORMAT_ONLINE and FORMAT_OTHER,
and they are in the same context.
Verifies that if the "format" field in a program page contains the values
FORMAT_ONLINE, FORMAT_HYBRID, and FORMAT_OTHER, and they are in the same context.
"""
program_page = ProgramPageFactory.create(format=program_format)

Expand Down
6 changes: 3 additions & 3 deletions courses/serializers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import pytest
from django.contrib.auth.models import AnonymousUser

from cms.constants import FORMAT_ONLINE, FORMAT_OTHER
from cms.constants import FORMAT_HYBRID, FORMAT_ONLINE, FORMAT_OTHER
from cms.factories import FacultyMembersPageFactory
from courses.factories import (
CourseFactory,
Expand Down Expand Up @@ -52,7 +52,7 @@ def test_base_program_serializer():

@pytest.mark.parametrize("has_product", [True, False])
@pytest.mark.parametrize("is_external", [True, False])
@pytest.mark.parametrize("program_format", [FORMAT_ONLINE, FORMAT_OTHER])
@pytest.mark.parametrize("program_format", [FORMAT_ONLINE, FORMAT_HYBRID, FORMAT_OTHER])
@pytest.mark.parametrize(
"duration, time_commitment, video_url, ceus, external_marketing_url, marketing_hubspot_form_id", # noqa: PT006
[
Expand Down Expand Up @@ -184,7 +184,7 @@ def test_base_course_serializer():
@pytest.mark.parametrize("all_runs", [True, False])
@pytest.mark.parametrize("is_external", [True, False])
@pytest.mark.parametrize("course_page", [True, False])
@pytest.mark.parametrize("course_format", [FORMAT_ONLINE, FORMAT_OTHER])
@pytest.mark.parametrize("course_format", [FORMAT_ONLINE, FORMAT_HYBRID, FORMAT_OTHER])
@pytest.mark.parametrize(
"duration, time_commitment, video_url, ceus, external_marketing_url, marketing_hubspot_form_id", # noqa: PT006
[
Expand Down

0 comments on commit e71f785

Please sign in to comment.