From 07865ce0874cd6c4e8daa8d80c288ce7e860d217 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Wed, 21 Dec 2016 13:19:54 -0500 Subject: [PATCH] Revert "Merge pull request #14187 from edx/jia/MA-3052" This reverts commit f7a0c1d901c3a68375d98e3c7fab4fa5af80c591, reversing changes made to dec4034bc50aa144423e1d45cc15234e35020654. --- common/djangoapps/util/course.py | 30 ++++--------------- common/djangoapps/util/tests/test_course.py | 7 ++--- .../mobile_api/users/serializers.py | 6 ++-- 3 files changed, 10 insertions(+), 33 deletions(-) diff --git a/common/djangoapps/util/course.py b/common/djangoapps/util/course.py index f4ca0cb780..96a39cc762 100644 --- a/common/djangoapps/util/course.py +++ b/common/djangoapps/util/course.py @@ -11,40 +11,20 @@ from openedx.core.djangoapps.catalog.utils import get_run_marketing_url log = logging.getLogger(__name__) -def get_link_for_about_page(course_key, user): +def get_link_for_about_page(course_key, user, catalog_course_run=None): """ Returns the url to the course about page. """ assert isinstance(course_key, CourseKey) if settings.FEATURES.get('ENABLE_MKTG_SITE'): - marketing_url = get_run_marketing_url(course_key, user) + if catalog_course_run: + marketing_url = catalog_course_run.get('marketing_url') + else: + marketing_url = get_run_marketing_url(course_key, user) if marketing_url: return marketing_url - return get_lms_course_about_page_url(course_key) - - -def get_link_for_about_page_from_cache(course_key, catalog_course_run=None): - """ - Returns the url to the course about page from already cached dict if marketing - site is enabled else returns lms course about url. - """ - assert isinstance(course_key, CourseKey) - - if settings.FEATURES.get('ENABLE_MKTG_SITE'): - if catalog_course_run: - marketing_url = catalog_course_run.get('marketing_url') - if marketing_url: - return marketing_url - - return get_lms_course_about_page_url(course_key) - - -def get_lms_course_about_page_url(course_key): - """ - Returns lms about page url for course. - """ return u"{about_base_url}/courses/{course_key}/about".format( about_base_url=settings.LMS_ROOT_URL, course_key=unicode(course_key) diff --git a/common/djangoapps/util/tests/test_course.py b/common/djangoapps/util/tests/test_course.py index 158289caef..77fe7aaeeb 100644 --- a/common/djangoapps/util/tests/test_course.py +++ b/common/djangoapps/util/tests/test_course.py @@ -11,7 +11,7 @@ from openedx.core.djangoapps.catalog.utils import CatalogCacheUtility from openedx.core.djangoapps.catalog.tests.mixins import CatalogIntegrationMixin from openedx.core.djangolib.testing.utils import CacheIsolationTestCase from student.tests.factories import UserFactory -from util.course import get_link_for_about_page_from_cache, get_link_for_about_page +from util.course import get_link_for_about_page @httpretty.activate @@ -45,9 +45,6 @@ class CourseAboutLinkTestCase(CatalogIntegrationMixin, CacheIsolationTestCase): self.assertEquals( get_link_for_about_page(self.course_key, self.user), self.lms_course_about_url ) - self.assertEquals( - get_link_for_about_page_from_cache(self.course_key, self.course_run), self.lms_course_about_url - ) with mock.patch.dict('django.conf.settings.FEATURES', {'ENABLE_MKTG_SITE': True}): self.register_catalog_course_run_response( [self.course_key_string], [{"key": self.course_key_string, "marketing_url": None}] @@ -71,6 +68,6 @@ class CourseAboutLinkTestCase(CatalogIntegrationMixin, CacheIsolationTestCase): @mock.patch.dict('django.conf.settings.FEATURES', {'ENABLE_MKTG_SITE': True}) def test_about_page_marketing_url_cached(self): self.assertEquals( - get_link_for_about_page_from_cache(self.course_key, self.course_run), + get_link_for_about_page(self.course_key, self.user, self.course_run), self.course_run["marketing_url"] ) diff --git a/lms/djangoapps/mobile_api/users/serializers.py b/lms/djangoapps/mobile_api/users/serializers.py index a9d8e30ef7..5f734f2bf1 100644 --- a/lms/djangoapps/mobile_api/users/serializers.py +++ b/lms/djangoapps/mobile_api/users/serializers.py @@ -6,7 +6,7 @@ from rest_framework.reverse import reverse from courseware.access import has_access from certificates.api import certificate_downloadable_status from student.models import CourseEnrollment, User -from util.course import get_link_for_about_page_from_cache +from util.course import get_link_for_about_page class CourseOverviewField(serializers.RelatedField): @@ -50,8 +50,8 @@ class CourseOverviewField(serializers.RelatedField): } }, 'course_image': course_overview.course_image_url, - 'course_about': get_link_for_about_page_from_cache( - course_overview.id, self.context.get('catalog_course_run') + 'course_about': get_link_for_about_page( + course_overview.id, request.user, self.context.get('catalog_course_run') ), 'course_updates': reverse( 'course-updates-list',