FEATURE: admins can clear screend emails if needed

This commit is contained in:
Sam 2014-06-02 16:52:43 +10:00
parent 3f9a86a23a
commit 9e9c41ac52
8 changed files with 25 additions and 3 deletions

View File

@ -10,6 +10,13 @@ Discourse.AdminLogsScreenedEmailsController = Ember.ArrayController.extend(Disco
loading: false,
content: [],
clearBlock: function(row){
row.clearBlock().then(function(){
// feeling lazy
window.location.reload();
});
},
show: function() {
var self = this;
this.set('loading', true);

View File

@ -10,7 +10,11 @@
Discourse.ScreenedEmail = Discourse.Model.extend({
actionName: function() {
return I18n.t("admin.logs.screened_actions." + this.get('action'));
}.property('action')
}.property('action'),
clearBlock: function() {
return Discourse.ajax('/admin/logs/screened_emails/' + this.get('id'), {method: 'DELETE'});
}
});
Discourse.ScreenedEmail.reopenClass({

View File

@ -13,6 +13,7 @@
<div class="col heading last_match_at">{{i18n admin.logs.last_match_at}}</div>
<div class="col heading created_at">{{i18n admin.logs.created_at}}</div>
<div class="col heading ip_address">{{i18n admin.logs.ip_address}}</div>
<div class="col heading action"></div>
<div class="clearfix"></div>
</div>

View File

@ -6,4 +6,5 @@
<div class="col last_match_at">{{unboundAgeWithTooltip last_match_at}}</div>
<div class="col created_at">{{unboundAgeWithTooltip created_at}}</div>
<div class="col ip_address">{{ip_address}}</div>
<div class="col action"><button class="btn" {{action clearBlock this}}><i class='fa fa-check'></i> {{i18n admin.logs.screened_emails.actions.allow}}</button></div>
<div class="clearfix"></div>

View File

@ -5,4 +5,10 @@ class Admin::ScreenedEmailsController < Admin::AdminController
render_serialized(screened_emails, ScreenedEmailSerializer)
end
def destroy
screen = ScreenedEmail.find(params[:id].to_i)
screen.destroy!
render json: success_json
end
end

View File

@ -4,7 +4,8 @@ class ScreenedEmailSerializer < ApplicationSerializer
:match_count,
:last_match_at,
:created_at,
:ip_address
:ip_address,
:id
def action
ScreenedEmail.actions.key(object.action_type).to_s

View File

@ -1613,6 +1613,8 @@ en:
title: "Screened Emails"
description: "When someone tries to create a new account, the following email addresses will be checked and the registration will be blocked, or some other action performed."
email: "Email Address"
actions:
allow: "Allow"
screened_urls:
title: "Screened URLs"
description: "The URLs listed here were used in posts by users who have been identified as spammers."

View File

@ -86,7 +86,7 @@ Discourse::Application.routes.draw do
scope "/logs" do
resources :staff_action_logs, only: [:index]
resources :screened_emails, only: [:index]
resources :screened_emails, only: [:index, :destroy]
resources :screened_ip_addresses, only: [:index, :create, :update, :destroy]
resources :screened_urls, only: [:index]
end