Commit 3a6b2c30 by Zia Fazal

hide certificate configuration activate/deactivate and delete buttons

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