diff --git a/cms/djangoapps/contentstore/api/tests/test_quality.py b/cms/djangoapps/contentstore/api/tests/test_quality.py index 0ef6720db9..4addfed5be 100644 --- a/cms/djangoapps/contentstore/api/tests/test_quality.py +++ b/cms/djangoapps/contentstore/api/tests/test_quality.py @@ -125,6 +125,7 @@ class CourseQualityViewTest(SharedModuleStoreTestCase, APITestCase): 'total_visible': 1, 'total_number': 1, 'highlights_enabled': False, + 'highlights_active_for_course': False, }, 'subsections': { 'num_with_one_block_type': 1, diff --git a/cms/djangoapps/contentstore/api/tests/test_validation.py b/cms/djangoapps/contentstore/api/tests/test_validation.py index 87b580d7bc..d7036e26c3 100644 --- a/cms/djangoapps/contentstore/api/tests/test_validation.py +++ b/cms/djangoapps/contentstore/api/tests/test_validation.py @@ -92,6 +92,7 @@ class CourseValidationViewTest(SharedModuleStoreTestCase, APITestCase): 'has_update': True, }, 'certificates': { + 'is_enabled': True, 'is_activated': False, 'has_certificate': False, }, @@ -101,5 +102,4 @@ class CourseValidationViewTest(SharedModuleStoreTestCase, APITestCase): }, 'is_self_paced': True, } - self.assertDictEqual(resp.data, expected_data) diff --git a/cms/djangoapps/contentstore/api/views/course_quality.py b/cms/djangoapps/contentstore/api/views/course_quality.py index e2ecfc841a..4bff8e3c2d 100644 --- a/cms/djangoapps/contentstore/api/views/course_quality.py +++ b/cms/djangoapps/contentstore/api/views/course_quality.py @@ -5,6 +5,7 @@ from scipy import stats from rest_framework.generics import GenericAPIView from rest_framework.response import Response +from contentstore.views.item import highlights_setting from edxval.api import get_videos_for_course from openedx.core.djangoapps.request_cache.middleware import request_cached from openedx.core.lib.api.view_utils import DeveloperErrorViewMixin, view_auth_classes @@ -122,12 +123,13 @@ class CourseQualityView(DeveloperErrorViewMixin, GenericAPIView): def _sections_quality(self, course): sections, visible_sections = self._get_sections(course) - sections_with_highlights = [s for s in visible_sections if s.highlights] + sections_with_highlights = [section for section in visible_sections if section.highlights] return dict( total_number=len(sections), total_visible=len(visible_sections), number_with_highlights=len(sections_with_highlights), - highlights_enabled=course.highlights_enabled_for_messaging, + highlights_active_for_course=course.highlights_enabled_for_messaging, + highlights_enabled=highlights_setting.is_enabled(), ) def _subsections_quality(self, course, request): diff --git a/cms/djangoapps/contentstore/api/views/course_validation.py b/cms/djangoapps/contentstore/api/views/course_validation.py index b69b414561..a05704c0ad 100644 --- a/cms/djangoapps/contentstore/api/views/course_validation.py +++ b/cms/djangoapps/contentstore/api/views/course_validation.py @@ -205,9 +205,11 @@ class CourseValidationView(DeveloperErrorViewMixin, GenericAPIView): def _certificates_validation(self, course): is_activated, certificates = CertificateManager.is_activated(course) + certificates_enabled = certificates is not None return dict( is_activated=is_activated, - has_certificate=len(certificates) > 0, + has_certificate=certificates_enabled and len(certificates) > 0, + is_enabled=certificates_enabled, ) def _updates_validation(self, course, request): diff --git a/cms/templates/checklists.html b/cms/templates/checklists.html index 8951a5c33d..6c6bf24643 100644 --- a/cms/templates/checklists.html +++ b/cms/templates/checklists.html @@ -2,11 +2,13 @@ <%inherit file="base.html" /> <%def name="online_help_token()"><% return "files" %> <%! + from cms.djangoapps.contentstore import utils from cms.djangoapps.contentstore.config.waffle_utils import should_show_checklists_quality from django.core.urlresolvers import reverse from django.utils.translation import ugettext as _ from openedx.core.djangolib.markup import HTML, Text from openedx.core.djangolib.js_utils import js_escaped_string, dump_js_escaped_json + from util.course import has_certificates_enabled %> <%block name="title">${_("Checklists")} <%block name="bodyclass">is-signedin course view-checklists @@ -34,8 +36,12 @@
<%static:studiofrontend entry="courseHealthCheck"> - <% - course_key = context_course.id + + <% + course_key = unicode(context_course.id) + certificates_url = '' + if has_certificates_enabled(context_course): + certificates_url = utils.reverse_course_url('certificates_list_handler', course_key) %> { "lang": "${language_code | n, js_escaped_string}", @@ -54,11 +60,11 @@ }, "enable_quality": ${should_show_checklists_quality(context_course.id) | n, dump_js_escaped_json}, "links": { - "certificates": ${reverse('certificates_list_handler', kwargs={'course_key_string': unicode(course_key)})| n, dump_js_escaped_json}, - "course_outline": ${reverse('course_handler', kwargs={'course_key_string': unicode(course_key)})| n, dump_js_escaped_json}, - "course_updates": ${reverse('course_info_handler', kwargs={'course_key_string': unicode(course_key)})| n, dump_js_escaped_json}, - "grading_policy": ${reverse('grading_handler', kwargs={'course_key_string': unicode(course_key)})| n, dump_js_escaped_json}, - "settings": ${reverse('settings_handler', kwargs={'course_key_string': unicode(course_key)})| n, dump_js_escaped_json} + "certificates": ${certificates_url | n, dump_js_escaped_json}, + "course_outline": ${utils.reverse_course_url('course_handler', course_key) | n, dump_js_escaped_json}, + "course_updates": ${utils.reverse_course_url('course_info_handler', course_key) | n, dump_js_escaped_json}, + "grading_policy": ${utils.reverse_course_url('grading_handler', course_key) | n, dump_js_escaped_json}, + "settings": ${utils.reverse_course_url('settings_handler', course_key) | n, dump_js_escaped_json} } } diff --git a/common/djangoapps/util/course.py b/common/djangoapps/util/course.py index f4405d8902..598e703456 100644 --- a/common/djangoapps/util/course.py +++ b/common/djangoapps/util/course.py @@ -57,3 +57,14 @@ def get_link_for_about_page(course): ) return course_about_url + + +def has_certificates_enabled(course): + """ + Arguments: + course: This can be either a course overview object or a course descriptor. + Returns a boolean if the course has enabled certificates + """ + if not settings.FEATURES.get('CERTIFICATES_HTML_VIEW', False): + return False + return course.cert_html_view_enabled