Change deprecated *_filter methods to *_action

This commit is contained in:
Patrick Gansterer 2019-10-28 21:11:35 +01:00
parent bee671c90e
commit 2100c738af
39 changed files with 66 additions and 66 deletions

View File

@ -1,5 +1,5 @@
class Admin::BaseController < ApplicationController class Admin::BaseController < ApplicationController
before_filter :authenticate_admin before_action :authenticate_admin
def index def index
@user = current_user @user = current_user

View File

@ -7,9 +7,9 @@ class ApplicationController < ActionController::Base
helper_method :available_locales helper_method :available_locales
protect_from_forgery protect_from_forgery
before_filter :authenticate, :set_user_last_activity, :store_controller, :items_per_page before_action :authenticate, :set_user_last_activity, :store_controller, :items_per_page
after_filter :remove_controller after_action :remove_controller
around_filter :set_time_zone, :set_currency around_action :set_time_zone, :set_currency
# Returns the controller handling the current request. # Returns the controller handling the current request.
@ -30,7 +30,7 @@ class ApplicationController < ActionController::Base
# To disable a controller in the plugin, you can use this as a `before_action`: # To disable a controller in the plugin, you can use this as a `before_action`:
# #
# class MypluginController < ApplicationController # class MypluginController < ApplicationController
# before_filter -> { require_plugin_enabled FoodsoftMyplugin } # before_action -> { require_plugin_enabled FoodsoftMyplugin }
# end # end
# #
def require_plugin_enabled(plugin) def require_plugin_enabled(plugin)

View File

@ -2,7 +2,7 @@ class ArticleCategoriesController < ApplicationController
inherit_resources # Build default REST Actions via plugin inherit_resources # Build default REST Actions via plugin
before_filter :authenticate_article_meta before_action :authenticate_article_meta
def create def create
create!(:notice => I18n.t('article_categories.create.notice')) { article_categories_path } create!(:notice => I18n.t('article_categories.create.notice')) { article_categories_path }

View File

@ -1,6 +1,6 @@
# encoding: utf-8 # encoding: utf-8
class ArticlesController < ApplicationController class ArticlesController < ApplicationController
before_filter :authenticate_article_meta, :find_supplier before_action :authenticate_article_meta, :find_supplier
def index def index
if params['sort'] if params['sort']

View File

@ -1,12 +1,12 @@
# Controller concern to handle foodcoop scope # Controller concern to handle foodcoop scope
# #
# Includes a +before_filter+ for selecting foodcoop from url. # Includes a +before_action+ for selecting foodcoop from url.
# #
module Concerns::FoodcoopScope module Concerns::FoodcoopScope
extend ActiveSupport::Concern extend ActiveSupport::Concern
included do included do
before_filter :select_foodcoop before_action :select_foodcoop
end end
private private

View File

@ -2,7 +2,7 @@ module Concerns::Locale
extend ActiveSupport::Concern extend ActiveSupport::Concern
included do included do
before_filter :set_locale before_action :set_locale
end end
def explicitly_requested_language def explicitly_requested_language

View File

@ -1,8 +1,8 @@
# encoding: utf-8 # encoding: utf-8
class DeliveriesController < ApplicationController class DeliveriesController < ApplicationController
before_filter :find_supplier, :exclude => :fill_new_stock_article_form before_action :find_supplier, :exclude => :fill_new_stock_article_form
def index def index
@deliveries = @supplier.deliveries.order('delivered_on DESC') @deliveries = @supplier.deliveries.order('delivered_on DESC')
end end

View File

@ -1,7 +1,7 @@
class ErrorsController < ApplicationController class ErrorsController < ApplicationController
include Gaffe::Errors include Gaffe::Errors
skip_before_filter :authenticate skip_before_action :authenticate
layout :current_layout layout :current_layout

View File

@ -1,5 +1,5 @@
class Finance::BankTransactionsController < ApplicationController class Finance::BankTransactionsController < ApplicationController
before_filter :authenticate_finance before_action :authenticate_finance
inherit_resources inherit_resources
def index def index

View File

@ -1,5 +1,5 @@
class Finance::BaseController < ApplicationController class Finance::BaseController < ApplicationController
before_filter :authenticate_finance before_action :authenticate_finance
def index def index
@financial_transactions = FinancialTransaction.includes(:ordergroup).order('created_on DESC').limit(8) @financial_transactions = FinancialTransaction.includes(:ordergroup).order('created_on DESC').limit(8)

View File

@ -1,5 +1,5 @@
class Finance::FinancialLinksController < Finance::BaseController class Finance::FinancialLinksController < Finance::BaseController
before_filter :find_financial_link, except: [:create] before_action :find_financial_link, except: [:create]
def show def show
@items = @financial_link.bank_transactions.map do |bt| @items = @financial_link.bank_transactions.map do |bt|

View File

@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
class Finance::FinancialTransactionsController < ApplicationController class Finance::FinancialTransactionsController < ApplicationController
before_filter :authenticate_finance before_action :authenticate_finance
before_filter :find_ordergroup, :except => [:new_collection, :create_collection, :index_collection] before_action :find_ordergroup, :except => [:new_collection, :create_collection, :index_collection]
inherit_resources inherit_resources
# belongs_to :ordergroup # belongs_to :ordergroup

View File

@ -1,7 +1,7 @@
class Finance::InvoicesController < ApplicationController class Finance::InvoicesController < ApplicationController
before_filter :find_invoice, only: [:show, :edit, :update, :destroy] before_action :find_invoice, only: [:show, :edit, :update, :destroy]
before_filter :ensure_can_edit, only: [:edit, :update, :destroy] before_action :ensure_can_edit, only: [:edit, :update, :destroy]
def index def index
@invoices = Invoice.includes(:supplier, :deliveries, :orders).order('date DESC').page(params[:page]).per(@per_page) @invoices = Invoice.includes(:supplier, :deliveries, :orders).order('date DESC').page(params[:page]).per(@per_page)

View File

@ -1,6 +1,6 @@
class Foodcoop::WorkgroupsController < ApplicationController class Foodcoop::WorkgroupsController < ApplicationController
before_filter :authenticate_membership_or_admin, before_action :authenticate_membership_or_admin,
:except => [:index] :except => [:index]
def index def index

View File

@ -1,7 +1,7 @@
class GroupOrderArticlesController < ApplicationController class GroupOrderArticlesController < ApplicationController
before_filter :authenticate_finance before_action :authenticate_finance
before_filter :find_group_order_article, except: [:new, :create] before_action :find_group_order_article, except: [:new, :create]
layout false # We only use this controller to server js snippets, no need for layout rendering layout false # We only use this controller to server js snippets, no need for layout rendering

View File

@ -2,10 +2,10 @@
# Management actions that require the "orders" role are handled by the OrdersController. # Management actions that require the "orders" role are handled by the OrdersController.
class GroupOrdersController < ApplicationController class GroupOrdersController < ApplicationController
# Security # Security
before_filter :ensure_ordergroup_member before_action :ensure_ordergroup_member
before_filter :ensure_open_order, :only => [:new, :create, :edit, :update, :order, :stock_order, :saveOrder] before_action :ensure_open_order, :only => [:new, :create, :edit, :update, :order, :stock_order, :saveOrder]
before_filter :ensure_my_group_order, only: [:show, :edit, :update] before_action :ensure_my_group_order, only: [:show, :edit, :update]
before_filter :enough_apples?, only: [:new, :create] before_action :enough_apples?, only: [:new, :create]
# Index page. # Index page.
def index def index
@ -66,7 +66,7 @@ class GroupOrdersController < ApplicationController
private private
# Returns true if @current_user is member of an Ordergroup. # Returns true if @current_user is member of an Ordergroup.
# Used as a :before_filter by OrdersController. # Used as a :before_action by OrdersController.
def ensure_ordergroup_member def ensure_ordergroup_member
@ordergroup = @current_user.ordergroup @ordergroup = @current_user.ordergroup
if @ordergroup.nil? if @ordergroup.nil?

View File

@ -1,8 +1,8 @@
class InvitesController < ApplicationController class InvitesController < ApplicationController
before_filter :authenticate_membership_or_admin_for_invites before_action :authenticate_membership_or_admin_for_invites
before_filter -> { require_config_disabled :disable_invite } before_action -> { require_config_disabled :disable_invite }
def new def new
@invite = Invite.new(:user => @current_user, :group => @group) @invite = Invite.new(:user => @current_user, :group => @group)
end end

View File

@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
class LoginController < ApplicationController class LoginController < ApplicationController
skip_before_filter :authenticate # no authentication since this is the login page skip_before_action :authenticate # no authentication since this is the login page
before_filter :validate_token, :only => [:new_password, :update_password] before_action :validate_token, :only => [:new_password, :update_password]
# Display the form to enter an email address requesting a token to set a new password. # Display the form to enter an email address requesting a token to set a new password.
def forgot_password def forgot_password

View File

@ -1,6 +1,6 @@
class OrderArticlesController < ApplicationController class OrderArticlesController < ApplicationController
before_filter :authenticate_finance_or_orders before_action :authenticate_finance_or_orders
layout false # We only use this controller to serve js snippets, no need for layout rendering layout false # We only use this controller to serve js snippets, no need for layout rendering

View File

@ -5,9 +5,9 @@
class OrdersController < ApplicationController class OrdersController < ApplicationController
include Concerns::SendOrderPdf include Concerns::SendOrderPdf
before_filter :authenticate_pickups_or_orders before_action :authenticate_pickups_or_orders
before_filter :authenticate_orders, except: [:receive, :receive_on_order_article_create, :receive_on_order_article_update, :show] before_action :authenticate_orders, except: [:receive, :receive_on_order_article_create, :receive_on_order_article_update, :show]
before_filter :remove_empty_article, only: [:create, :update] before_action :remove_empty_article, only: [:create, :update]
# List orders # List orders
def index def index

View File

@ -1,6 +1,6 @@
class PickupsController < ApplicationController class PickupsController < ApplicationController
before_filter :authenticate_pickups before_action :authenticate_pickups
def index def index
@orders = Order.finished_not_closed.order('pickup DESC').group_by { |o| o.pickup } @orders = Order.finished_not_closed.order('pickup DESC').group_by { |o| o.pickup }

View File

@ -1,6 +1,6 @@
class SessionsController < ApplicationController class SessionsController < ApplicationController
skip_before_filter :authenticate skip_before_action :authenticate
layout 'login' layout 'login'
def new def new

View File

@ -1,6 +1,6 @@
# Foodcoop-specific styling # Foodcoop-specific styling
class StylesController < ApplicationController class StylesController < ApplicationController
skip_before_filter :authenticate skip_before_action :authenticate
# renders foodcoop css, or 404 if not configured # renders foodcoop css, or 404 if not configured
# #

View File

@ -1,6 +1,6 @@
# encoding: utf-8 # encoding: utf-8
class SuppliersController < ApplicationController class SuppliersController < ApplicationController
before_filter :authenticate_suppliers, :except => [:index, :list] before_action :authenticate_suppliers, :except => [:index, :list]
helper :deliveries helper :deliveries
def index def index

View File

@ -1,8 +1,8 @@
# encoding: utf-8 # encoding: utf-8
class CurrentOrders::ArticlesController < ApplicationController class CurrentOrders::ArticlesController < ApplicationController
before_filter :authenticate_orders before_action :authenticate_orders
before_filter :find_order_and_order_article, only: [:index, :show] before_action :find_order_and_order_article, only: [:index, :show]
def index def index
# sometimes need to pass id as parameter for forms # sometimes need to pass id as parameter for forms

View File

@ -1,6 +1,6 @@
class CurrentOrders::GroupOrdersController < ApplicationController class CurrentOrders::GroupOrdersController < ApplicationController
# Security # Security
before_filter :ensure_ordergroup_member before_action :ensure_ordergroup_member
def index def index
# XXX code duplication lib/foodsoft_current_orders/app/controllers/current_orders/ordergroups_controller.rb # XXX code duplication lib/foodsoft_current_orders/app/controllers/current_orders/ordergroups_controller.rb

View File

@ -1,8 +1,8 @@
# encoding: utf-8 # encoding: utf-8
class CurrentOrders::OrdergroupsController < ApplicationController class CurrentOrders::OrdergroupsController < ApplicationController
before_filter :authenticate_orders before_action :authenticate_orders
before_filter :find_group_orders, only: [:index, :show] before_action :find_group_orders, only: [:index, :show]
def index def index
# sometimes need to pass id as parameter for forms # sometimes need to pass id as parameter for forms

View File

@ -1,6 +1,6 @@
class CurrentOrders::OrdersController < ApplicationController class CurrentOrders::OrdersController < ApplicationController
before_filter :authenticate_orders, except: :my before_action :authenticate_orders, except: :my
def show def show
@doc_options ||= {} @doc_options ||= {}

View File

@ -1,6 +1,6 @@
# encoding: utf-8 # encoding: utf-8
class CurrentOrdersController < ApplicationController class CurrentOrdersController < ApplicationController
before_filter :authenticate_orders before_action :authenticate_orders
end end

View File

@ -1,6 +1,6 @@
class DiscourseController < ApplicationController class DiscourseController < ApplicationController
before_filter -> { require_plugin_enabled FoodsoftDiscourse } before_action -> { require_plugin_enabled FoodsoftDiscourse }
protected protected

View File

@ -1,7 +1,7 @@
class DiscourseLoginController < DiscourseController class DiscourseLoginController < DiscourseController
before_filter -> { require_config_disabled :discourse_sso } before_action -> { require_config_disabled :discourse_sso }
skip_before_filter :authenticate skip_before_action :authenticate
def initiate def initiate
discourse_url = FoodsoftConfig[:discourse_url] discourse_url = FoodsoftConfig[:discourse_url]

View File

@ -1,6 +1,6 @@
class DiscourseSsoController < DiscourseController class DiscourseSsoController < DiscourseController
before_filter -> { require_config_enabled :discourse_sso } before_action -> { require_config_enabled :discourse_sso }
def sso def sso
raise I18n.t('discourse.sso.invalid_signature') unless valid_signature? raise I18n.t('discourse.sso.invalid_signature') unless valid_signature?

View File

@ -1,7 +1,7 @@
require 'filemagic' require 'filemagic'
class DocumentsController < ApplicationController class DocumentsController < ApplicationController
before_filter -> { require_plugin_enabled FoodsoftDocuments } before_action -> { require_plugin_enabled FoodsoftDocuments }
def index def index
if params["sort"] if params["sort"]

View File

@ -1,6 +1,6 @@
class MessageThreadsController < ApplicationController class MessageThreadsController < ApplicationController
before_filter -> { require_plugin_enabled FoodsoftMessages } before_action -> { require_plugin_enabled FoodsoftMessages }
def index def index
@groups = Group.order(:name) @groups = Group.order(:name)

View File

@ -1,6 +1,6 @@
class MessagesController < ApplicationController class MessagesController < ApplicationController
before_filter -> { require_plugin_enabled FoodsoftMessages } before_action -> { require_plugin_enabled FoodsoftMessages }
# Renders the "inbox" action. # Renders the "inbox" action.
def index def index

View File

@ -2,9 +2,9 @@ class PrinterController < ApplicationController
include Concerns::SendOrderPdf include Concerns::SendOrderPdf
include Tubesock::Hijack include Tubesock::Hijack
skip_before_filter :authenticate skip_before_action :authenticate
before_filter :authenticate_printer before_action :authenticate_printer
before_filter -> { require_plugin_enabled FoodsoftPrinter } before_action -> { require_plugin_enabled FoodsoftPrinter }
def socket def socket
hijack do |tubesock| hijack do |tubesock|

View File

@ -1,7 +1,7 @@
class PrinterJobsController < ApplicationController class PrinterJobsController < ApplicationController
include Concerns::SendOrderPdf include Concerns::SendOrderPdf
before_filter -> { require_plugin_enabled FoodsoftPrinter } before_action -> { require_plugin_enabled FoodsoftPrinter }
def index def index
jobs = PrinterJob.includes(:printer_job_updates) jobs = PrinterJob.includes(:printer_job_updates)

View File

@ -10,7 +10,7 @@ module FoodsoftUservoice
module LoadUservoice module LoadUservoice
def self.included(base) # :nodoc: def self.included(base) # :nodoc:
base.class_eval do base.class_eval do
before_filter :add_uservoice_script before_action :add_uservoice_script
protected protected

View File

@ -1,13 +1,13 @@
# encoding: utf-8 # encoding: utf-8
class PagesController < ApplicationController class PagesController < ApplicationController
before_filter -> { require_plugin_enabled FoodsoftWiki } before_action -> { require_plugin_enabled FoodsoftWiki }
before_filter :catch_special_pages, only: [:show, :new] before_action :catch_special_pages, only: [:show, :new]
skip_before_filter :authenticate, :only => :all skip_before_action :authenticate, :only => :all
before_filter :only => :all do before_action :only => :all do
authenticate_or_token(['wiki', 'all']) authenticate_or_token(['wiki', 'all'])
end end
before_filter do before_action do
content_for :head, view_context.rss_meta_tag content_for :head, view_context.rss_meta_tag
end end