From c14f0b14eabb34fc7423db08e78a21fe54168c53 Mon Sep 17 00:00:00 2001 From: Diana Huang Date: Mon, 24 Apr 2017 11:16:27 -0400 Subject: [PATCH] Course jump tos should go to the main course home page. --- common/test/acceptance/tests/studio/test_studio_outline.py | 2 ++ lms/djangoapps/courseware/url_helpers.py | 7 ++++++- lms/djangoapps/courseware/views/views.py | 6 ++++-- lms/djangoapps/verify_student/views.py | 1 - 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/common/test/acceptance/tests/studio/test_studio_outline.py b/common/test/acceptance/tests/studio/test_studio_outline.py index 5a4b0fe685..9288a38014 100644 --- a/common/test/acceptance/tests/studio/test_studio_outline.py +++ b/common/test/acceptance/tests/studio/test_studio_outline.py @@ -1442,6 +1442,8 @@ class DefaultStatesContentTest(CourseOutlineTest): __test__ = True + # TODO: TNL-6546: Removing unified_course_view_flag + # This test will need to be rewritten to point to the new course home page. def test_view_live(self): """ Scenario: View Live version from course outline diff --git a/lms/djangoapps/courseware/url_helpers.py b/lms/djangoapps/courseware/url_helpers.py index b4da0a59de..a5ef5eeafa 100644 --- a/lms/djangoapps/courseware/url_helpers.py +++ b/lms/djangoapps/courseware/url_helpers.py @@ -9,12 +9,15 @@ from xmodule.modulestore.search import path_to_location, navigation_index from xmodule.modulestore.django import modulestore -def get_redirect_url(course_key, usage_key): +# TODO: TNL-6547: Remove unified_course_view parameter +def get_redirect_url(course_key, usage_key, unified_course_view=False): """ Returns the redirect url back to courseware Args: course_id(str): Course Id string location(str): The location id of course component + unified_course_view (bool): temporary parameter while this feature is behind a waffle flag. + Is the unified_course_view waffle flag on? Raises: ItemNotFoundError if no data at the location or NoPathToItem if location not in any class @@ -22,6 +25,8 @@ def get_redirect_url(course_key, usage_key): Returns: Redirect url string """ + if usage_key.block_type == 'course' and unified_course_view: + return reverse('edx.course_experience.course_home', args=[unicode(course_key)]) ( course_key, chapter, section, vertical_unused, diff --git a/lms/djangoapps/courseware/views/views.py b/lms/djangoapps/courseware/views/views.py index 5d7c6c8876..91bb15e3df 100644 --- a/lms/djangoapps/courseware/views/views.py +++ b/lms/djangoapps/courseware/views/views.py @@ -4,6 +4,7 @@ Courseware views functions import json import logging import urllib +import waffle from collections import OrderedDict, namedtuple from datetime import datetime @@ -210,7 +211,7 @@ def jump_to_id(request, course_id, module_id): @ensure_csrf_cookie -def jump_to(_request, course_id, location): +def jump_to(request, course_id, location): """ Show the page that contains a specific location. @@ -225,7 +226,8 @@ def jump_to(_request, course_id, location): except InvalidKeyError: raise Http404(u"Invalid course_key or usage_key") try: - redirect_url = get_redirect_url(course_key, usage_key) + unified_course_view = waffle.flag_is_active(request, 'unified_course_view') + redirect_url = get_redirect_url(course_key, usage_key, unified_course_view=unified_course_view) except ItemNotFoundError: raise Http404(u"No data at this location: {0}".format(usage_key)) except NoPathToItem: diff --git a/lms/djangoapps/verify_student/views.py b/lms/djangoapps/verify_student/views.py index 8ffd364067..ca72ea3ea5 100644 --- a/lms/djangoapps/verify_student/views.py +++ b/lms/djangoapps/verify_student/views.py @@ -29,7 +29,6 @@ from opaque_keys.edx.keys import CourseKey from commerce.utils import EcommerceService from course_modes.models import CourseMode -from courseware.url_helpers import get_redirect_url from edx_rest_api_client.exceptions import SlumberBaseException from edxmako.shortcuts import render_to_response, render_to_string from openedx.core.djangoapps.embargo import api as embargo_api