From bb7c993f4a40ecf5d5433421a22d8621c6bf3792 Mon Sep 17 00:00:00 2001 From: evazion Date: Sat, 24 Aug 2019 22:55:36 -0500 Subject: [PATCH] app controller: clean up helpers. * Move `show_moderation_notice?` out. * Don't need to declare `helper :pagination` manually. --- app/controllers/application_controller.rb | 10 ++-------- app/helpers/application_helper.rb | 4 ++++ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index b1831e66c..e3baa63c4 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,17 +2,15 @@ class ApplicationController < ActionController::Base class ApiLimitError < StandardError; end skip_forgery_protection if: -> { SessionLoader.new(request).has_api_authentication? } - helper :pagination before_action :reset_current_user before_action :set_current_user - after_action :reset_current_user before_action :normalize_search before_action :api_check before_action :set_variant before_action :track_only_param - layout "default" - helper_method :show_moderation_notice? before_action :enable_cors + after_action :reset_current_user + layout "default" rescue_from Exception, :with => :rescue_exception rescue_from User::PrivilegeError, :with => :access_denied @@ -31,10 +29,6 @@ class ApplicationController < ActionController::Base end end - def show_moderation_notice? - CurrentUser.can_approve_posts? && (cookies[:moderated].blank? || Time.at(cookies[:moderated].to_i) < 20.hours.ago) - end - def enable_cors response.headers["Access-Control-Allow-Origin"] = "*" end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index b75d64569..6ccc59144 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -217,6 +217,10 @@ module ApplicationHelper end end + def show_moderation_notice? + CurrentUser.can_approve_posts? && (cookies[:moderated].blank? || Time.at(cookies[:moderated].to_i) < 20.hours.ago) + end + protected def nav_link_match(controller, url) url =~ case controller