Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorPatricio Cano <suprnova32@gmail.com>2016-08-01 20:14:03 +0300
committerPatricio Cano <suprnova32@gmail.com>2016-08-15 21:18:15 +0300
commitabf2dcd25c4a176801314872733ede91297d1ab0 (patch)
tree581aceab4c6a341bb6532145a1907ed4b9a25760 /app
parent64ab2b3d9f10366249c03a6bcf5e8b1d20010d8f (diff)
Allow `SpamLog` to be submitted as ham
- Added `submitted_as_ham` to `SpamLog` to mark which logs have been submitted to Akismet. - Added routes and controller action.
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin/spam_logs_controller.rb11
-rw-r--r--app/models/spam_log.rb4
-rw-r--r--app/views/admin/spam_logs/_spam_log.html.haml5
3 files changed, 18 insertions, 2 deletions
diff --git a/app/controllers/admin/spam_logs_controller.rb b/app/controllers/admin/spam_logs_controller.rb
index bc6fce0ec4e..d15f00bf84c 100644
--- a/app/controllers/admin/spam_logs_controller.rb
+++ b/app/controllers/admin/spam_logs_controller.rb
@@ -1,4 +1,6 @@
class Admin::SpamLogsController < Admin::ApplicationController
+ include Gitlab::AkismetHelper
+
def index
@spam_logs = SpamLog.order(id: :desc).page(params[:page])
end
@@ -15,9 +17,14 @@ class Admin::SpamLogsController < Admin::ApplicationController
end
end
- def ham
+ def mark_as_ham
spam_log = SpamLog.find(params[:id])
- Gitlab::AkismetHelper.ham!(spam_log.source_ip, spam_log.user_agent, spam_log.description, spam_log.user)
+ if ham!(spam_log.source_ip, spam_log.user_agent, spam_log.text, spam_log.user)
+ spam_log.update_attribute(:submitted_as_ham, true)
+ redirect_to admin_spam_logs_path, notice: 'Spam log successfully submitted as ham.'
+ else
+ redirect_to admin_spam_logs_path, notice: 'Error with Akismet. Please check the logs for more info.'
+ end
end
end
diff --git a/app/models/spam_log.rb b/app/models/spam_log.rb
index 12df68ef83b..3b8b9833565 100644
--- a/app/models/spam_log.rb
+++ b/app/models/spam_log.rb
@@ -7,4 +7,8 @@ class SpamLog < ActiveRecord::Base
user.block
user.destroy
end
+
+ def text
+ [title, description].join("\n")
+ end
end
diff --git a/app/views/admin/spam_logs/_spam_log.html.haml b/app/views/admin/spam_logs/_spam_log.html.haml
index 8aea67f4497..f2b6106fb4a 100644
--- a/app/views/admin/spam_logs/_spam_log.html.haml
+++ b/app/views/admin/spam_logs/_spam_log.html.haml
@@ -24,6 +24,11 @@
= link_to 'Remove user', admin_spam_log_path(spam_log, remove_user: true),
data: { confirm: "USER #{user.name} WILL BE REMOVED! Are you sure?" }, method: :delete, class: "btn btn-xs btn-remove"
%td
+ - if spam_log.submitted_as_ham?
+ .btn.btn-xs.disabled
+ Submitted as Ham
+ - else
+ = link_to 'Submit as ham', mark_as_ham_admin_spam_log_path(spam_log), method: :post, class: 'btn btn-xs btn-warning'
- if user && !user.blocked?
= link_to 'Block user', block_admin_user_path(user), data: {confirm: 'USER WILL BE BLOCKED! Are you sure?'}, method: :put, class: "btn btn-xs"
- else