From 9e9c41ac523c581fe8c682287ada25c98694275d Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 2 Jun 2014 16:52:43 +1000 Subject: [PATCH] FEATURE: admins can clear screend emails if needed --- .../controllers/admin_logs_screened_emails_controller.js | 7 +++++++ app/assets/javascripts/admin/models/screened_email.js | 6 +++++- .../admin/templates/logs/screened_emails.js.handlebars | 1 + .../templates/logs/screened_emails_list_item.js.handlebars | 1 + app/controllers/admin/screened_emails_controller.rb | 6 ++++++ app/serializers/screened_email_serializer.rb | 3 ++- config/locales/client.en.yml | 2 ++ config/routes.rb | 2 +- 8 files changed, 25 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/admin/controllers/admin_logs_screened_emails_controller.js b/app/assets/javascripts/admin/controllers/admin_logs_screened_emails_controller.js index 2a38efc0a..f81f632f0 100644 --- a/app/assets/javascripts/admin/controllers/admin_logs_screened_emails_controller.js +++ b/app/assets/javascripts/admin/controllers/admin_logs_screened_emails_controller.js @@ -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); diff --git a/app/assets/javascripts/admin/models/screened_email.js b/app/assets/javascripts/admin/models/screened_email.js index c2a3065b2..5e6a8ddf8 100644 --- a/app/assets/javascripts/admin/models/screened_email.js +++ b/app/assets/javascripts/admin/models/screened_email.js @@ -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({ diff --git a/app/assets/javascripts/admin/templates/logs/screened_emails.js.handlebars b/app/assets/javascripts/admin/templates/logs/screened_emails.js.handlebars index 8ebe3cc02..94e2e4267 100644 --- a/app/assets/javascripts/admin/templates/logs/screened_emails.js.handlebars +++ b/app/assets/javascripts/admin/templates/logs/screened_emails.js.handlebars @@ -13,6 +13,7 @@
{{i18n admin.logs.last_match_at}}
{{i18n admin.logs.created_at}}
{{i18n admin.logs.ip_address}}
+
diff --git a/app/assets/javascripts/admin/templates/logs/screened_emails_list_item.js.handlebars b/app/assets/javascripts/admin/templates/logs/screened_emails_list_item.js.handlebars index 367a2090f..cfffc7fd5 100644 --- a/app/assets/javascripts/admin/templates/logs/screened_emails_list_item.js.handlebars +++ b/app/assets/javascripts/admin/templates/logs/screened_emails_list_item.js.handlebars @@ -6,4 +6,5 @@
{{unboundAgeWithTooltip last_match_at}}
{{unboundAgeWithTooltip created_at}}
{{ip_address}}
+
diff --git a/app/controllers/admin/screened_emails_controller.rb b/app/controllers/admin/screened_emails_controller.rb index 92847e39e..014a3844a 100644 --- a/app/controllers/admin/screened_emails_controller.rb +++ b/app/controllers/admin/screened_emails_controller.rb @@ -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 diff --git a/app/serializers/screened_email_serializer.rb b/app/serializers/screened_email_serializer.rb index 79c03345b..44d28af23 100644 --- a/app/serializers/screened_email_serializer.rb +++ b/app/serializers/screened_email_serializer.rb @@ -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 diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index d0f6e84b9..7d6de9592 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -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." diff --git a/config/routes.rb b/config/routes.rb index 8b347cf50..5972ff254 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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