Skip to content

Commit

Permalink
fix: ensure course run key is passed in legacy enrollment urls
Browse files Browse the repository at this point in the history
  • Loading branch information
adamstankiewicz committed Dec 16, 2024
1 parent 1ded448 commit 0487f81
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion enterprise_catalog/apps/catalog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
get_parent_content_key,
localized_utcnow,
)
from enterprise_catalog.apps.catalog.algolia_utils import get_advertised_course_run


LOGGER = getLogger(__name__)
Expand Down Expand Up @@ -555,10 +556,19 @@ def get_content_enrollment_url(self, content_metadata):
else:
# Catalog param only needed for legacy (non-learner-portal) enrollment URLs
params['catalog'] = self.uuid

course_key = content_key if parent_content_key else None
course_run_key = content_key if not parent_content_key else None

if parent_content_key:
advertised_course_run = get_advertised_course_run(content_metadata.json_metadata)
if advertised_course_run:
course_run_key = advertised_course_run['key']

url = '{}/enterprise/{}/course/{}/enroll/'.format(
settings.LMS_BASE_URL,
self.enterprise_uuid,
content_key,
course_run_key or course_key,
)

return update_query_parameters(url, params)
Expand Down

0 comments on commit 0487f81

Please sign in to comment.