diff --git a/app/controllers/ajax/report_controller.rb b/app/controllers/ajax/report_controller.rb index 6e6ef762..0c6f4082 100644 --- a/app/controllers/ajax/report_controller.rb +++ b/app/controllers/ajax/report_controller.rb @@ -5,13 +5,14 @@ class Ajax::ReportController < AjaxController @response[:status] = :err - if current_user.nil? - @response[:message] = I18n.t('messages.report.create.login') + unless user_signed_in? + @response[:status] = :noauth + @response[:message] = t(".noauth") return end unless %w(answer comment question user).include? params[:type] - @response[:message] = I18n.t('messages.report.create.unknown') + @response[:message] = t(".unknown") return end @@ -31,14 +32,14 @@ class Ajax::ReportController < AjaxController end if object.nil? - @response[:message] = I18n.t('messages.report.create.not_found', parameter: params[:type]) + @response[:message] = t(".notfound", parameter: params[:type]) return end current_user.report object, params[:reason] @response[:status] = :okay - @response[:message] = I18n.t('messages.report.create.okay', parameter: params[:type]) + @response[:message] = t(".success", parameter: params[:type]) @response[:success] = true end end diff --git a/config/locales/controllers.en.yml b/config/locales/controllers.en.yml index 8c4da416..841a40ad 100644 --- a/config/locales/controllers.en.yml +++ b/config/locales/controllers.en.yml @@ -114,6 +114,12 @@ en: follow: success: "Successfully unfollowed user." error: "You are not following that user." + report: + create: + noauth: :messages.noauth + unknown: "You can't report this entity." + notfound: "Could not find %{parameter}" + success: "%{parameter} reported. A moderator will decide what happens with the %{parameter}." smile: create: success: "Successfully smiled answer." diff --git a/config/locales/en.yml b/config/locales/en.yml index 05357e3b..edfbfd83 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -56,12 +56,6 @@ en: error: "An error occurred." parameter_error: "%{parameter} is required." noauth: "requires authentication" - report: - create: - login: "login required" - unknown: "unknown type" - not_found: "Could not find %{parameter}" - okay: "%{parameter} reported. A moderator will decide what happens with the %{parameter}." subscription: torpedo: "418 I'm a torpedo" views: