Merge pull request #13125 from edx/renzo/multiple-program-types
Allow program listing page to display programs from any category
This commit is contained in:
@@ -23,7 +23,6 @@ from openedx.core.djangoapps.credentials.tests.mixins import CredentialsApiConfi
|
||||
from openedx.core.djangoapps.programs.models import ProgramsApiConfig
|
||||
from openedx.core.djangoapps.programs.tests import factories as programs_factories
|
||||
from openedx.core.djangoapps.programs.tests.mixins import ProgramsApiConfigMixin
|
||||
from openedx.core.djangoapps.programs.utils import get_display_category
|
||||
from student.tests.factories import UserFactory, CourseEnrollmentFactory
|
||||
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import CourseFactory
|
||||
@@ -65,8 +64,6 @@ class TestProgramListing(ProgramsApiConfigMixin, CredentialsApiConfigMixin, Shar
|
||||
|
||||
cls.data = sorted([cls.first_program, cls.second_program], key=cls.program_sort_key)
|
||||
|
||||
cls.marketing_root = urljoin(settings.MKTG_URLS.get('ROOT'), 'xseries').rstrip('/')
|
||||
|
||||
def setUp(self):
|
||||
super(TestProgramListing, self).setUp()
|
||||
|
||||
@@ -187,30 +184,19 @@ class TestProgramListing(ProgramsApiConfigMixin, CredentialsApiConfigMixin, Shar
|
||||
|
||||
for index, actual_program in enumerate(actual):
|
||||
expected_program = self.data[index]
|
||||
|
||||
self.assert_dict_contains_subset(actual_program, expected_program)
|
||||
self.assertEqual(
|
||||
actual_program['display_category'],
|
||||
get_display_category(expected_program)
|
||||
)
|
||||
|
||||
def test_toggle_xseries_advertising(self):
|
||||
def test_program_discovery(self):
|
||||
"""
|
||||
Verify that when XSeries advertising is disabled, no link to the marketing site
|
||||
appears in the response (and vice versa).
|
||||
Verify that a link to a programs marketing page appears in the response.
|
||||
"""
|
||||
# Verify the URL is present when advertising is enabled.
|
||||
self.create_programs_config()
|
||||
self.create_programs_config(marketing_path='bar')
|
||||
self.mock_programs_api(self.data)
|
||||
|
||||
response = self.client.get(self.url)
|
||||
self.assertContains(response, self.marketing_root)
|
||||
|
||||
# Verify the URL is missing when advertising is disabled.
|
||||
self.create_programs_config(xseries_ad_enabled=False)
|
||||
marketing_root = urljoin(settings.MKTG_URLS.get('ROOT'), 'bar').rstrip('/')
|
||||
|
||||
response = self.client.get(self.url)
|
||||
self.assertNotContains(response, self.marketing_root)
|
||||
self.assertContains(response, marketing_root)
|
||||
|
||||
def test_links_to_detail_pages(self):
|
||||
"""
|
||||
@@ -237,7 +223,8 @@ class TestProgramListing(ProgramsApiConfigMixin, CredentialsApiConfigMixin, Shar
|
||||
)
|
||||
|
||||
# Verify that links to the marketing site are present when detail pages are disabled.
|
||||
self.create_programs_config(program_details_enabled=False)
|
||||
self.create_programs_config(program_details_enabled=False, marketing_path='bar')
|
||||
marketing_root = urljoin(settings.MKTG_URLS.get('ROOT'), 'bar').rstrip('/')
|
||||
|
||||
response = self.client.get(self.url)
|
||||
actual = self.load_serialized_data(response, 'programsData')
|
||||
@@ -248,7 +235,7 @@ class TestProgramListing(ProgramsApiConfigMixin, CredentialsApiConfigMixin, Shar
|
||||
|
||||
self.assertEqual(
|
||||
actual_program['detail_url'],
|
||||
'{}/{}'.format(self.marketing_root, expected_program['marketing_slug'])
|
||||
'{}/{}'.format(marketing_root, expected_program['marketing_slug'])
|
||||
)
|
||||
|
||||
def test_certificates_listed(self):
|
||||
|
||||
@@ -5,7 +5,7 @@ from . import views
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^programs/$', views.view_programs, name='program_listing_view'),
|
||||
url(r'^programs/$', views.program_listing, name='program_listing_view'),
|
||||
# Matches paths like 'programs/123/' and 'programs/123/foo/', but not 'programs/123/foo/bar/'.
|
||||
url(r'^programs/(?P<program_id>\d+)/[\w\-]*/?$', views.program_details, name='program_details_view'),
|
||||
]
|
||||
|
||||
@@ -8,19 +8,16 @@ from django.http import Http404
|
||||
from django.views.decorators.http import require_GET
|
||||
|
||||
from edxmako.shortcuts import render_to_response
|
||||
from lms.djangoapps.learner_dashboard.utils import strip_course_id, FAKE_COURSE_KEY
|
||||
from openedx.core.djangoapps.credentials.utils import get_programs_credentials
|
||||
from openedx.core.djangoapps.programs.models import ProgramsApiConfig
|
||||
from openedx.core.djangoapps.programs import utils
|
||||
from lms.djangoapps.learner_dashboard.utils import (
|
||||
FAKE_COURSE_KEY,
|
||||
strip_course_id
|
||||
)
|
||||
|
||||
|
||||
@login_required
|
||||
@require_GET
|
||||
def view_programs(request):
|
||||
"""View programs in which the user is engaged."""
|
||||
def program_listing(request):
|
||||
"""View a list of programs in which the user is engaged."""
|
||||
programs_config = ProgramsApiConfig.current()
|
||||
if not programs_config.show_program_listing:
|
||||
raise Http404
|
||||
@@ -28,22 +25,20 @@ def view_programs(request):
|
||||
meter = utils.ProgramProgressMeter(request.user)
|
||||
programs = meter.engaged_programs
|
||||
|
||||
# TODO: Pull 'xseries' string from configuration model.
|
||||
marketing_root = urljoin(settings.MKTG_URLS.get('ROOT'), 'xseries').rstrip('/')
|
||||
marketing_url = urljoin(settings.MKTG_URLS.get('ROOT'), programs_config.marketing_path).rstrip('/')
|
||||
|
||||
for program in programs:
|
||||
program['detail_url'] = utils.get_program_detail_url(program, marketing_root)
|
||||
program['display_category'] = utils.get_display_category(program)
|
||||
program['detail_url'] = utils.get_program_detail_url(program, marketing_url)
|
||||
|
||||
context = {
|
||||
'credentials': get_programs_credentials(request.user),
|
||||
'disable_courseware_js': True,
|
||||
'marketing_url': marketing_url,
|
||||
'nav_hidden': True,
|
||||
'programs': programs,
|
||||
'progress': meter.progress,
|
||||
'xseries_url': marketing_root if programs_config.show_xseries_ad else None,
|
||||
'nav_hidden': True,
|
||||
'show_program_listing': programs_config.show_program_listing,
|
||||
'credentials': get_programs_credentials(request.user, category='xseries'),
|
||||
'disable_courseware_js': True,
|
||||
'uses_pattern_library': True
|
||||
'uses_pattern_library': True,
|
||||
}
|
||||
|
||||
return render_to_response('learner_dashboard/programs.html', context)
|
||||
|
||||
Reference in New Issue
Block a user