FIX: delete spammer modal doesn't show the email address

This commit is contained in:
Régis Hanol 2014-10-06 21:55:52 +02:00
parent baee5c95ac
commit ac069d22a9
3 changed files with 43 additions and 26 deletions

View File

@ -367,30 +367,46 @@ Discourse.AdminUser = Discourse.User.extend({
deleteAsSpammer: function(successCallback) { deleteAsSpammer: function(successCallback) {
var user = this; var user = this;
var message = I18n.t('flagging.delete_confirm', {posts: user.get('post_count'), topics: user.get('topic_count'), email: user.get('email'), ip_address: user.get('ip_address')});
var buttons = [{ user.checkEmail().then(function() {
"label": I18n.t("composer.cancel"), var data = {
"class": "cancel-inline", posts: user.get('post_count'),
"link": true topics: user.get('topic_count'),
}, { email: user.get('email') || I18n.t("flagging.hidden_email_address"),
"label": '<i class="fa fa-exclamation-triangle"></i> ' + I18n.t("flagging.yes_delete_spammer"), ip_address: user.get('ip_address') || I18n.t("flagging.ip_address_missing")
"class": "btn btn-danger", };
"callback": function() { var message = I18n.t('flagging.delete_confirm', data);
Discourse.ajax("/admin/users/" + user.get('id') + '.json', { var buttons = [{
type: 'DELETE', "label": I18n.t("composer.cancel"),
data: {delete_posts: true, block_email: true, block_urls: true, block_ip: true, context: window.location.pathname} "class": "cancel-inline",
}).then(function(data) { "link": true
if (data.deleted) { }, {
if (successCallback) successCallback(); "label": '<i class="fa fa-exclamation-triangle"></i> ' + I18n.t("flagging.yes_delete_spammer"),
} else { "class": "btn btn-danger",
"callback": function() {
Discourse.ajax("/admin/users/" + user.get('id') + '.json', {
type: 'DELETE',
data: {
delete_posts: true,
block_email: true,
block_urls: true,
block_ip: true,
context: window.location.pathname
}
}).then(function(result) {
if (result.deleted) {
if (successCallback) successCallback();
} else {
bootbox.alert(I18n.t("admin.user.delete_failed"));
}
}, function() {
bootbox.alert(I18n.t("admin.user.delete_failed")); bootbox.alert(I18n.t("admin.user.delete_failed"));
} });
}, function() { }
bootbox.alert(I18n.t("admin.user.delete_failed")); }];
}); bootbox.dialog(message, buttons, {"classes": "flagging-delete-spammer"});
} });
}];
bootbox.dialog(message, buttons, {"classes": "flagging-delete-spammer"});
}, },
loadDetails: function() { loadDetails: function() {

View File

@ -416,15 +416,14 @@ Discourse.User = Discourse.Model.extend({
return Discourse.ajax("/users/" + this.get("username_lower") + "/emails.json", { return Discourse.ajax("/users/" + this.get("username_lower") + "/emails.json", {
type: "PUT", type: "PUT",
data: { context: window.location.pathname } data: { context: window.location.pathname }
}) }).then(function (result) {
.then(function (result) {
if (result) { if (result) {
self.setProperties({ self.setProperties({
email: result.email, email: result.email,
associated_accounts: result.associated_accounts associated_accounts: result.associated_accounts
}); });
} }
}); }, function () {});
} }
}); });

View File

@ -1309,6 +1309,8 @@ en:
delete_spammer: "Delete Spammer" delete_spammer: "Delete Spammer"
delete_confirm: "You are about to delete <b>%{posts}</b> posts and <b>%{topics}</b> topics from this user, remove their account, block signups from their IP address <b>%{ip_address}</b>, and add their email address <b>%{email}</b> to a permanent block list. Are you sure this user is really a spammer?" delete_confirm: "You are about to delete <b>%{posts}</b> posts and <b>%{topics}</b> topics from this user, remove their account, block signups from their IP address <b>%{ip_address}</b>, and add their email address <b>%{email}</b> to a permanent block list. Are you sure this user is really a spammer?"
yes_delete_spammer: "Yes, Delete Spammer" yes_delete_spammer: "Yes, Delete Spammer"
ip_address_missing: "(N/A)"
hidden_email_address: "(hidden)"
submit_tooltip: "Submit the private flag" submit_tooltip: "Submit the private flag"
take_action_tooltip: "Reach the flag threshold immediately, rather than waiting for more community flags" take_action_tooltip: "Reach the flag threshold immediately, rather than waiting for more community flags"
cant: "Sorry, you can't flag this post at this time." cant: "Sorry, you can't flag this post at this time."