Commit bed7d807 by Zia Fazal

enable certificate generation for html certificates

Enable Student-Generated Certificates for HTML certs flow
parent d3cb2e94
...@@ -7,6 +7,7 @@ import json ...@@ -7,6 +7,7 @@ import json
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.test.utils import override_settings from django.test.utils import override_settings
from django.conf import settings
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory from xmodule.modulestore.tests.factories import CourseFactory
from config_models.models import cache from config_models.models import cache
...@@ -94,6 +95,22 @@ class CertificatesInstructorDashTest(ModuleStoreTestCase): ...@@ -94,6 +95,22 @@ class CertificatesInstructorDashTest(ModuleStoreTestCase):
certs_api.set_cert_generation_enabled(self.course.id, True) certs_api.set_cert_generation_enabled(self.course.id, True)
self._assert_enable_certs_button(False) self._assert_enable_certs_button(False)
@mock.patch.dict(settings.FEATURES, {'CERTIFICATES_HTML_VIEW': True})
def test_show_enabled_button_for_html_certs(self):
"""
Tests `Enable Student-Generated Certificates` button is enabled
and `Generate Example Certificates` button is not available if
course has Web/HTML certificates view enabled.
"""
self.course.cert_html_view_enabled = True
self.course.save()
self.store.update_item(self.course, self.global_staff.id) # pylint: disable=no-member
self.client.login(username=self.global_staff.username, password="test")
response = self.client.get(self.url)
self.assertContains(response, 'Enable Student-Generated Certificates')
self.assertContains(response, 'enable-certificates-submit')
self.assertNotContains(response, 'Generate Example Certificates')
def _assert_certificates_visible(self, is_visible): def _assert_certificates_visible(self, is_visible):
"""Check that the certificates section is visible on the instructor dash. """ """Check that the certificates section is visible on the instructor dash. """
response = self.client.get(self.url) response = self.client.get(self.url)
......
...@@ -231,6 +231,11 @@ def _section_certificates(course): ...@@ -231,6 +231,11 @@ def _section_certificates(course):
dict dict
""" """
example_cert_status = None
html_cert_enabled = certs_api.has_html_certificates_enabled(course.id, course)
if html_cert_enabled:
can_enable_for_course = True
else:
example_cert_status = certs_api.example_certificates_status(course.id) example_cert_status = certs_api.example_certificates_status(course.id)
# Allow the user to enable self-generated certificates for students # Allow the user to enable self-generated certificates for students
...@@ -254,6 +259,7 @@ def _section_certificates(course): ...@@ -254,6 +259,7 @@ def _section_certificates(course):
'can_enable_for_course': can_enable_for_course, 'can_enable_for_course': can_enable_for_course,
'enabled_for_course': certs_api.cert_generation_enabled(course.id), 'enabled_for_course': certs_api.cert_generation_enabled(course.id),
'instructor_generation_enabled': instructor_generation_enabled, 'instructor_generation_enabled': instructor_generation_enabled,
'html_cert_enabled': html_cert_enabled,
'urls': { 'urls': {
'generate_example_certificates': reverse( 'generate_example_certificates': reverse(
'generate_example_certificates', 'generate_example_certificates',
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
<div class="certificates-wrapper"> <div class="certificates-wrapper">
<div class="example-certificates"> <div class="example-certificates">
% if not section_data['html_cert_enabled']:
<h2>${_('Example Certificates')}</h2> <h2>${_('Example Certificates')}</h2>
<div class="generate-example-certificates-wrapper"> <div class="generate-example-certificates-wrapper">
...@@ -13,6 +14,7 @@ ...@@ -13,6 +14,7 @@
<input type="submit" id="generate-example-certificates-submit" value="${_('Generate Example Certificates')}"/> <input type="submit" id="generate-example-certificates-submit" value="${_('Generate Example Certificates')}"/>
</form> </form>
</div> </div>
% endif
% if section_data['example_certificate_status'] is not None: % if section_data['example_certificate_status'] is not None:
<div class="example-certificate-status-wrapper"> <div class="example-certificate-status-wrapper">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment