Commit 8691c242 by Awais Jibran

Disable `Generate Exception Certificate button when web certificate config is deactive.

ECOM-4202
parent 7bca66c2
...@@ -14,7 +14,8 @@ ...@@ -14,7 +14,8 @@
function($, CertificateWhiteListListView, CertificateExceptionModel, CertificateWhiteListEditorView , function($, CertificateWhiteListListView, CertificateExceptionModel, CertificateWhiteListEditorView ,
CertificateWhiteListCollection, CertificateBulkWhiteList){ CertificateWhiteListCollection, CertificateBulkWhiteList){
return function(certificate_white_list_json, generate_certificate_exceptions_url, return function(certificate_white_list_json, generate_certificate_exceptions_url,
certificate_exception_view_url, generate_bulk_certificate_exceptions_url){ certificate_exception_view_url, generate_bulk_certificate_exceptions_url,
active_certificate){
var certificateWhiteList = new CertificateWhiteListCollection(certificate_white_list_json, { var certificateWhiteList = new CertificateWhiteListCollection(certificate_white_list_json, {
parse: true, parse: true,
...@@ -30,7 +31,8 @@ ...@@ -30,7 +31,8 @@
new CertificateWhiteListListView({ new CertificateWhiteListListView({
collection: certificateWhiteList, collection: certificateWhiteList,
certificateWhiteListEditorView: certificateWhiteListEditorView certificateWhiteListEditorView: certificateWhiteListEditorView,
active_certificate: active_certificate
}).render(); }).render();
new CertificateBulkWhiteList({ new CertificateBulkWhiteList({
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
initialize: function(options){ initialize: function(options){
this.certificateWhiteListEditorView = options.certificateWhiteListEditorView; this.certificateWhiteListEditorView = options.certificateWhiteListEditorView;
this.active_certificate = options.active_certificate;
// Re-render the view when an item is added to the collection // Re-render the view when an item is added to the collection
this.listenTo(this.collection, 'change add remove', this.render); this.listenTo(this.collection, 'change add remove', this.render);
}, },
...@@ -32,7 +33,7 @@ ...@@ -32,7 +33,7 @@
render: function(){ render: function(){
var template = this.loadTemplate('certificate-white-list'); var template = this.loadTemplate('certificate-white-list');
this.$el.html(template({certificates: this.collection.models})); this.$el.html(template({certificates: this.collection.models}));
if (this.collection.isEmpty()) { if (!this.active_certificate || this.collection.isEmpty()){
this.$("#generate-exception-certificates").addClass("is-disabled"); this.$("#generate-exception-certificates").addClass("is-disabled");
} }
else { else {
......
...@@ -182,7 +182,7 @@ define([ ...@@ -182,7 +182,7 @@ define([
setFixtures("<script type='text/template' id='certificate-white-list-tpl'>" + fixture + "</script>" + setFixtures("<script type='text/template' id='certificate-white-list-tpl'>" + fixture + "</script>" +
"<div class='white-listed-students' id='white-listed-students'></div>"); "<div class='white-listed-students' id='white-listed-students'></div>");
var certificate_white_list = new CertificateWhiteListCollection(certificates_exceptions_json, { this.certificate_white_list = new CertificateWhiteListCollection(certificates_exceptions_json, {
parse: true, parse: true,
canBeEmpty: true, canBeEmpty: true,
url: certificate_exception_url, url: certificate_exception_url,
...@@ -190,7 +190,10 @@ define([ ...@@ -190,7 +190,10 @@ define([
}); });
view = new CertificateWhiteListView({collection: certificate_white_list}); view = new CertificateWhiteListView({
collection: this.certificate_white_list,
active_certificate: true
});
view.render(); view.render();
}); });
...@@ -199,6 +202,22 @@ define([ ...@@ -199,6 +202,22 @@ define([
expect(view.$el.find('table tbody tr').length).toBe(2); expect(view.$el.find('table tbody tr').length).toBe(2);
}); });
it("verifies that Generate Exception Certificate button is disabled", function() {
expect(view.$el.find('table tbody tr').length).toBe(2);
expect(view.$el.find('#generate-exception-certificates').first()).not.toHaveClass('is-disabled');
// Render the view with active_certificate set to false.
view = new CertificateWhiteListView({
collection: this.certificate_white_list,
active_certificate: false
});
view.render();
// Verify that `Generate Exception Certificate` is disabled even when Collection is not empty.
expect(view.$el.find('#generate-exception-certificates').first()).toHaveClass('is-disabled');
expect(view.$el.find('table tbody tr').length).toBe(2);
});
it("verifies view is rendered on add/update to collection", function() { it("verifies view is rendered on add/update to collection", function() {
var user = 'test1', var user = 'test1',
notes = 'test1 notes updates', notes = 'test1 notes updates',
......
...@@ -7,7 +7,7 @@ from openedx.core.djangolib.js_utils import dump_js_escaped_json, js_escaped_str ...@@ -7,7 +7,7 @@ from openedx.core.djangolib.js_utils import dump_js_escaped_json, js_escaped_str
%> %>
<%static:require_module module_name="js/certificates/factories/certificate_whitelist_factory" class_name="CertificateWhitelistFactory"> <%static:require_module module_name="js/certificates/factories/certificate_whitelist_factory" class_name="CertificateWhitelistFactory">
CertificateWhitelistFactory(${certificate_white_list | n, dump_js_escaped_json}, '${generate_certificate_exceptions_url | n, js_escaped_string}', '${certificate_exception_view_url | n, js_escaped_string}', '${generate_bulk_certificate_exceptions_url | n, js_escaped_string}'); CertificateWhitelistFactory(${certificate_white_list | n, dump_js_escaped_json}, '${generate_certificate_exceptions_url | n, js_escaped_string}', '${certificate_exception_view_url | n, js_escaped_string}', '${generate_bulk_certificate_exceptions_url | n, js_escaped_string}', ${bool(section_data['active_certificate']) | n, dump_js_escaped_json});
</%static:require_module> </%static:require_module>
<%static:require_module module_name="js/certificates/factories/certificate_invalidation_factory" class_name="CertificateInvalidationFactory"> <%static:require_module module_name="js/certificates/factories/certificate_invalidation_factory" class_name="CertificateInvalidationFactory">
......
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