Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use single constant for course mode priority; only fetch catalog list with resolved course run #2298

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ Unreleased
----------
* nothing unreleased

[5.3.1]
-------
* fix: rely on single constant to define course mode priority order (i.e., ensure all enrollable modes are considered; previously missing honor mode in `enroll_learners_in_courses`).
* fix: prevent fetching catalog list without a resolved course run in the property `applicable_enterprise_catalog_uuids` within `DefaultEnterpriseEnrollmentIntention`.

[5.3.0]
--------
* refactor: Removed unused django setting.
Expand Down
2 changes: 1 addition & 1 deletion enterprise/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Your project description goes here.
"""

__version__ = "5.3.0"
__version__ = "5.3.1"
7 changes: 0 additions & 7 deletions enterprise/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,6 @@ class CourseModes:
UNPAID_EXECUTIVE_EDUCATION = 'unpaid-executive-education'


BEST_MODE_ORDER = [
CourseModes.VERIFIED,
CourseModes.PROFESSIONAL,
CourseModes.NO_ID_PROFESSIONAL,
CourseModes.UNPAID_EXECUTIVE_EDUCATION,
]
Comment on lines -63 to -68
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[inform/context] This removed constant has the same ordering as COURSE_MODE_SORT_ORDER, save for CourseModes.UNPAID_EXECUTIVE_EDUCATION. However, I believe this is OK as course runs with a seat mode of CourseModes.UNPAID_EXECUTIVE_EDUCATION do not have any seats with mode of CourseModes.AUDIT or CourseModes.HONOR.


# Course mode sorting based on slug
COURSE_MODE_SORT_ORDER = [
CourseModes.VERIFIED,
Expand Down
4 changes: 4 additions & 0 deletions enterprise/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2630,6 +2630,10 @@ def applicable_enterprise_catalog_uuids(self):
"""
Returns a list of UUIDs for applicable enterprise catalogs.
"""
if not self.course_run_key:
# Without a resolved course run key, prevent the enterprise catalog list from being fetched.
return []

contains_content_items_response = get_and_cache_enterprise_contains_content_items(
enterprise_customer_uuid=self.enterprise_customer.uuid,
content_keys=[self.course_run_key],
Expand Down
4 changes: 2 additions & 2 deletions enterprise/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

from enterprise.constants import (
ALLOWED_TAGS,
BEST_MODE_ORDER,
COURSE_MODE_SORT_ORDER,
DEFAULT_CATALOG_CONTENT_FILTER,
LMS_API_DATETIME_FORMAT,
LMS_API_DATETIME_FORMAT_WITHOUT_TIMEZONE,
Expand Down Expand Up @@ -2404,7 +2404,7 @@ def get_best_mode_from_course_key(course_key):
enterprise learner in.
"""
course_modes = [mode.slug for mode in CourseMode.objects.filter(course_id=course_key)]
if best_mode := [mode for mode in BEST_MODE_ORDER if mode in course_modes]:
if best_mode := [mode for mode in COURSE_MODE_SORT_ORDER if mode in course_modes]:
return best_mode[0]
return CourseModes.AUDIT

Expand Down
Loading