Disable cert generation for audit only courses
This commit is contained in:
@@ -359,7 +359,10 @@ def certificates_list_handler(request, course_key_string):
|
||||
course_id=course.id, include_expired=True
|
||||
) if mode.slug != 'audit'
|
||||
]
|
||||
if len(course_modes) > 0:
|
||||
|
||||
has_certificate_modes = len(course_modes) > 0
|
||||
|
||||
if has_certificate_modes:
|
||||
certificate_web_view_url = get_lms_link_for_certificate_web_view(
|
||||
user_id=request.user.id,
|
||||
course_key=course_key,
|
||||
@@ -382,6 +385,7 @@ def certificates_list_handler(request, course_key_string):
|
||||
'course_outline_url': course_outline_url,
|
||||
'upload_asset_url': upload_asset_url,
|
||||
'certificates': certificates,
|
||||
'has_certificate_modes': has_certificate_modes,
|
||||
'course_modes': course_modes,
|
||||
'certificate_web_view_url': certificate_web_view_url,
|
||||
'is_active': is_active,
|
||||
|
||||
@@ -195,6 +195,7 @@ class CertificatesBaseTestCase(object):
|
||||
self.assertTrue('must have name of the certificate' in context.exception)
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
@override_settings(FEATURES=FEATURES_WITH_CERTS_ENABLED)
|
||||
class CertificatesListHandlerTestCase(EventTestMixin, CourseTestCase, CertificatesBaseTestCase, HelperMethods):
|
||||
"""
|
||||
@@ -340,6 +341,40 @@ class CertificatesListHandlerTestCase(EventTestMixin, CourseTestCase, Certificat
|
||||
self.assertContains(response, 'verified')
|
||||
self.assertNotContains(response, 'audit')
|
||||
|
||||
def test_audit_only_disables_cert(self):
|
||||
"""
|
||||
Tests audit course mode is skipped when rendering certificates page.
|
||||
"""
|
||||
CourseModeFactory.create(course_id=self.course.id, mode_slug='audit')
|
||||
response = self.client.get_html(
|
||||
self._url(),
|
||||
)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, 'This course does not use a mode that offers certificates.')
|
||||
self.assertNotContains(response, 'This module is not enabled.')
|
||||
self.assertNotContains(response, 'Loading')
|
||||
|
||||
@ddt.data(
|
||||
['audit', 'verified'],
|
||||
['verified'],
|
||||
['audit', 'verified', 'credit'],
|
||||
['verified', 'credit'],
|
||||
['professional']
|
||||
)
|
||||
def test_non_audit_enables_cert(self, slugs):
|
||||
"""
|
||||
Tests audit course mode is skipped when rendering certificates page.
|
||||
"""
|
||||
for slug in slugs:
|
||||
CourseModeFactory.create(course_id=self.course.id, mode_slug=slug)
|
||||
response = self.client.get_html(
|
||||
self._url(),
|
||||
)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertNotContains(response, 'This course does not use a mode that offers certificates.')
|
||||
self.assertNotContains(response, 'This module is not enabled.')
|
||||
self.assertContains(response, 'Loading')
|
||||
|
||||
def test_assign_unique_identifier_to_certificates(self):
|
||||
"""
|
||||
Test certificates have unique ids
|
||||
|
||||
@@ -30,7 +30,9 @@ CMS.User.isGlobalStaff = '${is_global_staff}'=='True' ? true : false;
|
||||
|
||||
<%block name="requirejs">
|
||||
require(["js/certificates/factories/certificates_page_factory"], function(CertificatesPageFactory) {
|
||||
CertificatesPageFactory(${escape_json_dumps(certificates) | n}, "${certificate_url}", "${course_outline_url}", ${escape_json_dumps(course_modes) | n}, ${escape_json_dumps(certificate_web_view_url) | n}, ${escape_json_dumps(is_active) | n}, ${escape_json_dumps(certificate_activation_handler_url) | n} );
|
||||
if(${escape_json_dumps(has_certificate_modes)}) {
|
||||
CertificatesPageFactory(${escape_json_dumps(certificates) | n}, "${certificate_url}", "${course_outline_url}", ${escape_json_dumps(course_modes) | n}, ${escape_json_dumps(certificate_web_view_url) | n}, ${escape_json_dumps(is_active) | n}, ${escape_json_dumps(certificate_activation_handler_url) | n} );
|
||||
}
|
||||
});
|
||||
</%block>
|
||||
|
||||
@@ -56,6 +58,12 @@ CMS.User.isGlobalStaff = '${is_global_staff}'=='True' ? true : false;
|
||||
${_("This module is not enabled.")}
|
||||
</p>
|
||||
</div>
|
||||
% elif not has_certificate_modes:
|
||||
<div class="notice notice-incontext notice-moduledisabled">
|
||||
<p class="copy">
|
||||
${_("This course does not use a mode that offers certificates.")}
|
||||
</p>
|
||||
</div>
|
||||
% else:
|
||||
<div class="ui-loading">
|
||||
<p><span class="spin"><i class="icon fa fa-refresh" aria-hidden="true"></i></span> <span class="copy">${_("Loading")}</span></p>
|
||||
|
||||
@@ -3,7 +3,9 @@ Acceptance tests for Studio's Setting pages
|
||||
"""
|
||||
import re
|
||||
import uuid
|
||||
|
||||
from .base_studio_test import StudioCourseTest
|
||||
from ...pages.lms.create_mode import ModeCreationPage
|
||||
from ...pages.studio.settings_certificates import CertificatesPage
|
||||
from ...pages.studio.settings_advanced import AdvancedSettingsPage
|
||||
|
||||
@@ -28,6 +30,12 @@ class CertificatesTest(StudioCourseTest):
|
||||
)
|
||||
self.course_advanced_settings = dict()
|
||||
|
||||
# Add a verified mode to the course
|
||||
ModeCreationPage(
|
||||
self.browser, self.course_id, mode_slug=u'verified', mode_display_name=u'Verified Certificate',
|
||||
min_price=10, suggested_prices='10,20'
|
||||
).visit()
|
||||
|
||||
def make_signatory_data(self, prefix='First'):
|
||||
"""
|
||||
Makes signatory dict which can be used in the tests to create certificates
|
||||
|
||||
Reference in New Issue
Block a user