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
before_filter :authenticate_admin
before_action :authenticate_admin
def index
@user = current_user

View File

@ -7,9 +7,9 @@ class ApplicationController < ActionController::Base
helper_method :available_locales
protect_from_forgery
before_filter :authenticate, :set_user_last_activity, :store_controller, :items_per_page
after_filter :remove_controller
around_filter :set_time_zone, :set_currency
before_action :authenticate, :set_user_last_activity, :store_controller, :items_per_page
after_action :remove_controller
around_action :set_time_zone, :set_currency
# 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`:
#
# class MypluginController < ApplicationController
# before_filter -> { require_plugin_enabled FoodsoftMyplugin }
# before_action -> { require_plugin_enabled FoodsoftMyplugin }
# end
#
def require_plugin_enabled(plugin)

View File

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

View File

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

View File

@ -1,12 +1,12 @@
# 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
extend ActiveSupport::Concern
included do
before_filter :select_foodcoop
before_action :select_foodcoop
end
private

View File

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

View File

@ -1,8 +1,8 @@
# encoding: utf-8
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
@deliveries = @supplier.deliveries.order('delivered_on DESC')
end

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
class Finance::InvoicesController < ApplicationController
before_filter :find_invoice, only: [:show, :edit, :update, :destroy]
before_filter :ensure_can_edit, only: [:edit, :update, :destroy]
before_action :find_invoice, only: [:show, :edit, :update, :destroy]
before_action :ensure_can_edit, only: [:edit, :update, :destroy]
def index
@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
before_filter :authenticate_membership_or_admin,
before_action :authenticate_membership_or_admin,
:except => [:index]
def index

View File

@ -1,7 +1,7 @@
class GroupOrderArticlesController < ApplicationController
before_filter :authenticate_finance
before_filter :find_group_order_article, except: [:new, :create]
before_action :authenticate_finance
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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
# encoding: utf-8
class LoginController < ApplicationController
skip_before_filter :authenticate # no authentication since this is the login page
before_filter :validate_token, :only => [:new_password, :update_password]
skip_before_action :authenticate # no authentication since this is the login page
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.
def forgot_password

View File

@ -1,6 +1,6 @@
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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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