Skip to content

Commit

Permalink
fix: use single constant for course mode priority; only fetch catalog…
Browse files Browse the repository at this point in the history
… list with resolved course run
  • Loading branch information
adamstankiewicz committed Dec 4, 2024
1 parent 465e194 commit aced172
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
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"
8 changes: 0 additions & 8 deletions enterprise/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,6 @@ class CourseModes:
VERIFIED = 'verified'
UNPAID_EXECUTIVE_EDUCATION = 'unpaid-executive-education'


BEST_MODE_ORDER = [
CourseModes.VERIFIED,
CourseModes.PROFESSIONAL,
CourseModes.NO_ID_PROFESSIONAL,
CourseModes.UNPAID_EXECUTIVE_EDUCATION,
]

# 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

0 comments on commit aced172

Please sign in to comment.