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

[REFERENCE] fix: ensure course run key is passed in legacy enrollment urls #1017

Closed
Closed
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
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
Loading