debian-mirror-gitlab/app/controllers/concerns/spammable_actions.rb

26 lines
633 B
Ruby
Raw Normal View History

2016-09-13 17:45:13 +05:30
module SpammableActions
extend ActiveSupport::Concern
included do
before_action :authorize_submit_spammable!, only: :mark_as_spam
end
def mark_as_spam
if SpamService.new(spammable).mark_as_spam!
2016-11-03 12:29:30 +05:30
redirect_to spammable, notice: "#{spammable.class} was submitted to Akismet successfully."
2016-09-13 17:45:13 +05:30
else
redirect_to spammable, alert: 'Error with Akismet. Please check the logs for more info.'
end
end
private
def spammable
raise NotImplementedError, "#{self.class} does not implement #{__method__}"
end
def authorize_submit_spammable!
access_denied! unless current_user.admin?
end
end