Merge pull request #17362 from caesar2164/allow-about-sidebar-content-from-instructor
Add custom HTML to Course About page sidebar
This commit is contained in:
@@ -224,6 +224,7 @@ def get_course_about_section(request, course, section_key):
|
||||
|
||||
Valid keys:
|
||||
- overview
|
||||
- about_sidebar_html
|
||||
- short_description
|
||||
- description
|
||||
- key_dates (includes start, end, exams, etc)
|
||||
@@ -259,6 +260,7 @@ def get_course_about_section(request, course, section_key):
|
||||
'effort',
|
||||
'end_date',
|
||||
'prerequisites',
|
||||
'about_sidebar_html',
|
||||
'ocw_links'
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Test the about xblock
|
||||
"""
|
||||
import datetime
|
||||
|
||||
import ddt
|
||||
import pytz
|
||||
from ccx_keys.locator import CCXLocator
|
||||
from django.conf import settings
|
||||
@@ -12,9 +12,12 @@ from milestones.tests.utils import MilestonesTestCaseMixin
|
||||
from mock import patch
|
||||
from nose.plugins.attrib import attr
|
||||
from six import text_type
|
||||
from waffle.testutils import override_switch
|
||||
|
||||
from course_modes.models import CourseMode
|
||||
from lms.djangoapps.ccx.tests.factories import CcxFactory
|
||||
from openedx.features.course_experience.waffle import WAFFLE_NAMESPACE as COURSE_EXPERIENCE_WAFFLE_NAMESPACE
|
||||
from openedx.features.course_experience.waffle import ENABLE_COURSE_ABOUT_SIDEBAR_HTML
|
||||
from shoppingcart.models import Order, PaidCourseRegistration
|
||||
from student.models import CourseEnrollment
|
||||
from student.tests.factories import AdminFactory, CourseEnrollmentAllowedFactory, UserFactory
|
||||
@@ -417,6 +420,50 @@ class AboutWithClosedEnrollment(ModuleStoreTestCase):
|
||||
self.assertNotIn('<span class="important-dates-item-text">$10</span>', resp.content)
|
||||
|
||||
|
||||
@attr(shard=1)
|
||||
@ddt.ddt
|
||||
class AboutSidebarHTMLTestCase(SharedModuleStoreTestCase):
|
||||
"""
|
||||
This test case will check the About page for the content in the HTML sidebar.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(AboutSidebarHTMLTestCase, self).setUp()
|
||||
self.course = CourseFactory.create()
|
||||
|
||||
@ddt.data(
|
||||
("", "", False),
|
||||
("about_sidebar_html", "About Sidebar HTML Heading", False),
|
||||
("about_sidebar_html", "", False),
|
||||
("", "", True),
|
||||
("about_sidebar_html", "About Sidebar HTML Heading", True),
|
||||
("about_sidebar_html", "", True),
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_html_sidebar_enabled(self, itemfactory_display_name, itemfactory_data, waffle_switch_value):
|
||||
with override_switch(
|
||||
'{}.{}'.format(
|
||||
COURSE_EXPERIENCE_WAFFLE_NAMESPACE,
|
||||
ENABLE_COURSE_ABOUT_SIDEBAR_HTML
|
||||
),
|
||||
active=waffle_switch_value
|
||||
):
|
||||
if itemfactory_display_name:
|
||||
ItemFactory.create(
|
||||
category="about",
|
||||
parent_location=self.course.location,
|
||||
display_name=itemfactory_display_name,
|
||||
data=itemfactory_data,
|
||||
)
|
||||
url = reverse('about_course', args=[text_type(self.course.id)])
|
||||
resp = self.client.get(url)
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
if waffle_switch_value and itemfactory_display_name and itemfactory_data:
|
||||
self.assertIn('<section class="about-sidebar-html">', resp.content)
|
||||
self.assertIn(itemfactory_data, resp.content)
|
||||
else:
|
||||
self.assertNotIn('<section class="about-sidebar-html">', resp.content)
|
||||
|
||||
|
||||
@attr(shard=1)
|
||||
@patch.dict(settings.FEATURES, {'ENABLE_SHOPPING_CART': True})
|
||||
@patch.dict(settings.FEATURES, {'ENABLE_PAID_COURSE_REGISTRATION': True})
|
||||
|
||||
@@ -90,6 +90,8 @@ from openedx.core.djangolib.markup import HTML, Text
|
||||
from openedx.features.course_experience import UNIFIED_COURSE_TAB_FLAG, course_home_url_name
|
||||
from openedx.features.course_experience.course_tools import CourseToolsPluginManager
|
||||
from openedx.features.course_experience.views.course_dates import CourseDatesFragmentView
|
||||
from openedx.features.course_experience.waffle import waffle as course_experience_waffle
|
||||
from openedx.features.course_experience.waffle import ENABLE_COURSE_ABOUT_SIDEBAR_HTML
|
||||
from openedx.features.enterprise_support.api import data_sharing_consent_required
|
||||
from shoppingcart.utils import is_shopping_cart_enabled
|
||||
from student.models import CourseEnrollment, UserTestGroup
|
||||
@@ -835,6 +837,8 @@ def course_about(request, course_id):
|
||||
# Overview
|
||||
overview = CourseOverview.get_from_id(course.id)
|
||||
|
||||
sidebar_html_enabled = course_experience_waffle().is_enabled(ENABLE_COURSE_ABOUT_SIDEBAR_HTML)
|
||||
|
||||
# This local import is due to the circularity of lms and openedx references.
|
||||
# This may be resolved by using stevedore to allow web fragments to be used
|
||||
# as plugins, and to avoid the direct import.
|
||||
@@ -872,6 +876,7 @@ def course_about(request, course_id):
|
||||
'pre_requisite_courses': pre_requisite_courses,
|
||||
'course_image_urls': overview.image_urls,
|
||||
'reviews_fragment_view': reviews_fragment_view,
|
||||
'sidebar_html_enabled': sidebar_html_enabled,
|
||||
}
|
||||
|
||||
return render_to_response('courseware/course_about.html', context)
|
||||
|
||||
@@ -439,6 +439,12 @@
|
||||
background: url('#{$static-path}/images/link-icon.png') left center no-repeat;
|
||||
}
|
||||
}
|
||||
|
||||
&.about-sidebar-html {
|
||||
padding: 0 10px;
|
||||
box-shadow: none;
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
|
||||
header {
|
||||
|
||||
@@ -328,6 +328,13 @@ from six import string_types
|
||||
</div>
|
||||
%endif
|
||||
|
||||
% if sidebar_html_enabled:
|
||||
% if get_course_about_section(request, course, "about_sidebar_html"):
|
||||
<section class="about-sidebar-html">
|
||||
${get_course_about_section(request, course, "about_sidebar_html")}
|
||||
</section>
|
||||
% endif
|
||||
%endif
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user