Skip to content

Commit 02b8724

Browse files
committed
refactor: move filter out of if, extract about_base_url
1 parent b448b0f commit 02b8724

1 file changed

Lines changed: 14 additions & 13 deletions

File tree

common/djangoapps/util/course.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,24 +51,25 @@ def get_link_for_about_page(course):
5151
'SOCIAL_SHARING_SETTINGS',
5252
getattr(settings, 'SOCIAL_SHARING_SETTINGS', {})
5353
).get('CUSTOM_COURSE_URLS')
54+
5455
if use_catalog_mfe():
55-
course_about_url = f'{settings.CATALOG_MICROFRONTEND_URL}/courses/{course.id}/about'
56-
elif is_social_sharing_enabled and course.social_sharing_url:
56+
about_base_url = settings.CATALOG_MICROFRONTEND_URL
57+
else:
58+
about_base_url = configuration_helpers.get_value('LMS_ROOT_URL', settings.LMS_ROOT_URL)
59+
60+
if is_social_sharing_enabled and course.social_sharing_url:
5761
course_about_url = course.social_sharing_url
5862
elif settings.FEATURES.get('ENABLE_MKTG_SITE') and getattr(course, 'marketing_url', None):
5963
course_about_url = course.marketing_url
6064
else:
61-
course_about_url = '{about_base_url}/courses/{course_key}/about'.format(
62-
about_base_url=configuration_helpers.get_value('LMS_ROOT_URL', settings.LMS_ROOT_URL),
63-
course_key=str(course.id),
64-
)
65-
66-
## .. filter_implemented_name: CourseAboutPageURLRequested
67-
## .. filter_type: org.openedx.learning.course_about.page.url.requested.v1
68-
course_about_url, _ = CourseAboutPageURLRequested.run_filter(
69-
url=course_about_url,
70-
org=course.id.org,
71-
)
65+
course_about_url = f'{about_base_url}/courses/{course.id}/about'
66+
67+
## .. filter_implemented_name: CourseAboutPageURLRequested
68+
## .. filter_type: org.openedx.learning.course_about.page.url.requested.v1
69+
course_about_url, _ = CourseAboutPageURLRequested.run_filter(
70+
url=course_about_url,
71+
org=course.id.org,
72+
)
7273

7374
return course_about_url
7475

0 commit comments

Comments
 (0)