Commit 21318d14 by David Baumgold

Add confirmation prompt when deleting a user from a course team

parent 2617b478
...@@ -162,6 +162,14 @@ ...@@ -162,6 +162,14 @@
<%block name="jsextra"> <%block name="jsextra">
<script type="text/javascript"> <script type="text/javascript">
window.section = new CMS.Models.Section({
id: "${context_course.id}",
name: "${context_course.display_name_with_default | h}",
url_name: "${context_course.location.name | h}",
org: "${context_course.location.org | h}",
num: "${context_course.location.course | h}",
revision: "${context_course.location.revision | h}"
});
var staffEmails = ${json.dumps([user.email for user in staff])}; var staffEmails = ${json.dumps([user.email for user in staff])};
var tplUserURL = "${reverse('course_team_user', kwargs=dict( var tplUserURL = "${reverse('course_team_user', kwargs=dict(
org=context_course.location.org, org=context_course.location.org,
...@@ -270,38 +278,58 @@ ...@@ -270,38 +278,58 @@
}); });
$('.remove-user').click(function() { $('.remove-user').click(function() {
var url = tplUserURL.replace("@@EMAIL@@", $(this).data('id')) var email = $(this).data('id');
$.ajax({ var msg = new CMS.Views.Prompt.Warning({
url: url, title: gettext("Are you sure?"),
type: 'DELETE', message: _.template(gettext("Are you sure you want to delete {email} from the course team for {course}?"), {email: email, course: section.get('name')}, {interpolate: /\{(.+?)\}/g}),
dataType: 'json', actions: {
contentType: 'application/json', primary: {
success: function(data) { text: gettext("Delete"),
location.reload(); click: function(view) {
}, view.hide();
notifyOnError: false, var url = tplUserURL.replace("@@EMAIL@@", email)
error: function(jqXHR, textStatus, errorThrown) { $.ajax({
var message; url: url,
try { type: 'DELETE',
message = JSON.parse(jqXHR.responseText).error || "Unknown"; dataType: 'json',
} catch (e) { contentType: 'application/json',
message = "Unknown"; success: function(data) {
} location.reload();
var prompt = new CMS.Views.Prompt.Error({ },
title: gettext("Error removing user"), notifyOnError: false,
message: message, error: function(jqXHR, textStatus, errorThrown) {
actions: { var message;
primary: { try {
text: gettext("OK"), message = JSON.parse(jqXHR.responseText).error || "Unknown";
click: function(view) { } catch (e) {
view.hide(); message = "Unknown";
}
var prompt = new CMS.Views.Prompt.Error({
title: gettext("Error removing user"),
message: message,
actions: {
primary: {
text: gettext("OK"),
click: function(view) {
view.hide();
}
}
}
})
prompt.show();
} }
} });
} }
}) },
prompt.show(); secondary: {
text: gettext("Cancel"),
click: function(view) {
view.hide();
}
}
} }
}); });
msg.show();
}); });
$(".toggle-admin-role").click(function(e) { $(".toggle-admin-role").click(function(e) {
......
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