hide certificate configuration activate/deactivate and delete buttons
added line break
This commit is contained in:
@@ -375,6 +375,7 @@ def certificates_list_handler(request, course_key_string):
|
||||
'course_modes': course_modes,
|
||||
'certificate_web_view_url': certificate_web_view_url,
|
||||
'is_active': is_active,
|
||||
'is_global_staff': GlobalStaff().has_user(request.user),
|
||||
'certificate_activation_handler_url': activation_handler_url
|
||||
})
|
||||
elif "application/json" in request.META.get('HTTP_ACCEPT'):
|
||||
|
||||
@@ -55,10 +55,12 @@ function(_, Course, CertificatesCollection, CertificateModel, CertificateDetails
|
||||
course_modes: ['honor', 'test'],
|
||||
certificate_web_view_url: '/users/1/courses/orgX/009/2016'
|
||||
});
|
||||
window.CMS.User = {isGlobalStaff: true};
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
delete window.course;
|
||||
delete window.CMS.User;
|
||||
});
|
||||
|
||||
describe('Certificate Details Spec:', function() {
|
||||
@@ -141,6 +143,12 @@ function(_, Course, CertificatesCollection, CertificateModel, CertificateDetails
|
||||
expect(this.view.$('.action-delete .delete')).toExist();
|
||||
});
|
||||
|
||||
it('should not present a Delete action if user is not global staff', function () {
|
||||
window.CMS.User = {isGlobalStaff: false};
|
||||
appendSetFixtures(this.view.render().el);
|
||||
expect(this.view.$('.action-delete .delete')).not.toExist();
|
||||
});
|
||||
|
||||
it('should prompt the user when when clicking the Delete button', function(){
|
||||
expect(this.view.$('.action-delete .delete')).toExist();
|
||||
this.view.$('.action-delete .delete').click();
|
||||
|
||||
@@ -86,12 +86,12 @@ function(_, Course, CertificateModel, SignatoryModel, CertificatesCollection, Ce
|
||||
num: 'course_num',
|
||||
revision: 'course_rev'
|
||||
});
|
||||
|
||||
|
||||
window.CMS.User = {isGlobalStaff: true};
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
delete window.course;
|
||||
delete window.CMS.User;
|
||||
});
|
||||
|
||||
describe('Certificate editor view', function() {
|
||||
@@ -151,6 +151,12 @@ function(_, Course, CertificateModel, SignatoryModel, CertificatesCollection, Ce
|
||||
expect(this.view.$('.action-delete')).toExist();
|
||||
});
|
||||
|
||||
it('should not have delete button is user is not global staff', function() {
|
||||
window.CMS.User = {isGlobalStaff: false};
|
||||
appendSetFixtures(this.view.render().el);
|
||||
expect(this.view.$('.action-delete')).not.toExist();
|
||||
});
|
||||
|
||||
it('should save properly', function() {
|
||||
var requests = AjaxHelpers.requests(this),
|
||||
notificationSpy = ViewHelpers.createNotificationSpy();
|
||||
|
||||
@@ -18,7 +18,7 @@ function(_, $, Course, CertificatePreview, TemplateHelpers, ViewHelpers, AjaxHel
|
||||
preview_certificate: '.preview-certificate-link'
|
||||
};
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function() {
|
||||
window.course = new Course({
|
||||
id: '5',
|
||||
name: 'Course Name',
|
||||
@@ -27,11 +27,13 @@ function(_, $, Course, CertificatePreview, TemplateHelpers, ViewHelpers, AjaxHel
|
||||
num: 'course_num',
|
||||
revision: 'course_rev'
|
||||
});
|
||||
window.CMS.User = {isGlobalStaff: true};
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
delete window.course;
|
||||
});
|
||||
delete window.course;
|
||||
delete window.CMS.User;
|
||||
});
|
||||
|
||||
describe('Certificate Web Preview Spec:', function() {
|
||||
|
||||
@@ -85,6 +87,12 @@ function(_, $, Course, CertificatePreview, TemplateHelpers, ViewHelpers, AjaxHel
|
||||
expect(this.view.toggleCertificateActivation).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('toggle certificate activation button should not be present if user is not global staff', function () {
|
||||
window.CMS.User = {isGlobalStaff: false};
|
||||
appendSetFixtures(this.view.render().el);
|
||||
expect(this.view.$(SELECTORS.activate_certificate)).not.toExist();
|
||||
});
|
||||
|
||||
it('certificate deactivation works fine', function () {
|
||||
var requests = AjaxHelpers.requests(this),
|
||||
notificationSpy = ViewHelpers.createNotificationSpy();
|
||||
|
||||
@@ -22,7 +22,9 @@ from django.utils.translation import ugettext as _
|
||||
<script type="text/javascript">
|
||||
window.CMS = window.CMS || {};
|
||||
CMS.URL = CMS.URL || {};
|
||||
CMS.User = CMS.User || {};
|
||||
CMS.URL.UPLOAD_ASSET = '${upload_asset_url}';
|
||||
CMS.User.isGlobalStaff = '${is_global_staff}'=='True' ? true : false;
|
||||
</script>
|
||||
</%block>
|
||||
|
||||
|
||||
@@ -33,8 +33,10 @@
|
||||
<li class="action action-edit">
|
||||
<button class="edit"><i class="icon fa fa-pencil" aria-hidden="true"></i> <%= gettext("Edit") %></button>
|
||||
</li>
|
||||
<% if (CMS.User.isGlobalStaff) { %>
|
||||
<li class="action action-delete wrapper-delete-button" data-tooltip="<%= gettext('Delete') %>">
|
||||
<button class="delete action-icon"><i class="icon fa fa-trash-o" aria-hidden="true"></i><span><%= gettext("Delete") %></span></button>
|
||||
</li>
|
||||
<% } %>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
<div class="actions">
|
||||
<button class="action action-primary" type="submit"><% if (isNew) { print(gettext("Create")) } else { print(gettext("Save")) } %></button>
|
||||
<button class="action action-secondary action-cancel"><%= gettext("Cancel") %></button>
|
||||
<% if (!isNew) { %>
|
||||
<% if (!isNew && CMS.User.isGlobalStaff) { %>
|
||||
<span class="wrapper-delete-button">
|
||||
<a class="button action-delete delete" href="#"><%= gettext("Delete") %></a>
|
||||
</span>
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<a href=<%= certificate_web_view_url %> class="button preview-certificate-link" target="_blank">
|
||||
<%= gettext("Preview Certificate") %>
|
||||
</a>
|
||||
<% if (CMS.User.isGlobalStaff) { %>
|
||||
<button class="button activate-cert">
|
||||
<span>
|
||||
<% if(!is_active) { %>
|
||||
@@ -15,3 +16,4 @@
|
||||
<%= gettext("Deactivate") %></span>
|
||||
<% } %>
|
||||
</button>
|
||||
<% } %>
|
||||
|
||||
Reference in New Issue
Block a user