rename *_filter => *_action

This commit is contained in:
Vokhmin Alexey V 2015-03-05 02:19:19 +03:00
parent 5e5d3905e4
commit 84e7145d6d
52 changed files with 107 additions and 107 deletions

View File

@ -1,6 +1,6 @@
class AdvisoriesController < ApplicationController
before_filter :authenticate_user!
skip_before_filter :authenticate_user! if APP_CONFIG['anonymous_access']
before_action :authenticate_user!
skip_before_action :authenticate_user! if APP_CONFIG['anonymous_access']
load_resource find_by: :advisory_id
authorize_resource

View File

@ -1,8 +1,8 @@
class Api::V1::AdvisoriesController < Api::V1::BaseController
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, only: [:index, :show] if APP_CONFIG['anonymous_access']
before_action :authenticate_user!
skip_before_action :authenticate_user!, only: [:index, :show] if APP_CONFIG['anonymous_access']
load_resource :advisory, find_by: :advisory_id
before_filter :find_and_authorize_build_list, only: [:create, :update]
before_action :find_and_authorize_build_list, only: [:create, :update]
authorize_resource :build_list, only: [:create, :update]
def index

View File

@ -1,5 +1,5 @@
class Api::V1::ArchesController < Api::V1::BaseController
before_filter :authenticate_user! unless APP_CONFIG['anonymous_access']
before_action :authenticate_user! unless APP_CONFIG['anonymous_access']
def index
@arches = Arch.order(:id).paginate(paginate_params)

View File

@ -1,6 +1,6 @@
class Api::V1::BuildListsController < Api::V1::BaseController
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, only: [:show, :index] if APP_CONFIG['anonymous_access']
before_action :authenticate_user!
skip_before_action :authenticate_user!, only: [:show, :index] if APP_CONFIG['anonymous_access']
load_and_authorize_resource :build_list, only: [:show, :create, :cancel, :publish, :reject_publish, :create_container, :publish_into_testing, :rerun_tests]

View File

@ -1,7 +1,7 @@
class Api::V1::GroupsController < Api::V1::BaseController
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, only: [:show] if APP_CONFIG['anonymous_access']
before_action :authenticate_user!
skip_before_action :authenticate_user!, only: [:show] if APP_CONFIG['anonymous_access']
load_and_authorize_resource
def index

View File

@ -1,6 +1,6 @@
class Api::V1::IssuesController < Api::V1::BaseController
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, only: [:index, :group_index, :show] if APP_CONFIG['anonymous_access']
before_action :authenticate_user!
skip_before_action :authenticate_user!, only: [:index, :group_index, :show] if APP_CONFIG['anonymous_access']
load_and_authorize_resource :group, only: :group_index, find_by: :id, parent: false
load_and_authorize_resource :project

View File

@ -4,7 +4,7 @@ class Api::V1::JobsController < Api::V1::BaseController
QUEUES = %w(rpm_worker_observer)
QUEUE_CLASSES = %w(AbfWorker::RpmWorkerObserver)
before_filter :authenticate_user!
before_action :authenticate_user!
def shift
@build_list = BuildList.next_build(arch_ids, platform_ids) if current_user.system?

View File

@ -1,5 +1,5 @@
class Api::V1::MaintainersController < Api::V1::BaseController
before_filter :authenticate_user! unless APP_CONFIG['anonymous_access']
before_action :authenticate_user! unless APP_CONFIG['anonymous_access']
load_and_authorize_resource :platform
def index

View File

@ -1,7 +1,7 @@
class Api::V1::PlatformsController < Api::V1::BaseController
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, only: :allowed
skip_before_filter :authenticate_user!, only: [:show, :platforms_for_build, :members] if APP_CONFIG['anonymous_access']
before_action :authenticate_user!
skip_before_action :authenticate_user!, only: :allowed
skip_before_action :authenticate_user!, only: [:show, :platforms_for_build, :members] if APP_CONFIG['anonymous_access']
load_and_authorize_resource except: :allowed
def allowed

View File

@ -1,6 +1,6 @@
class Api::V1::ProductBuildListsController < Api::V1::BaseController
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, only: [:index, :show] if APP_CONFIG['anonymous_access']
before_action :authenticate_user!
skip_before_action :authenticate_user!, only: [:index, :show] if APP_CONFIG['anonymous_access']
load_and_authorize_resource :product, only: :index
load_and_authorize_resource

View File

@ -1,6 +1,6 @@
class Api::V1::ProductsController < Api::V1::BaseController
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, only: [:index, :show] if APP_CONFIG['anonymous_access']
before_action :authenticate_user!
skip_before_action :authenticate_user!, only: [:index, :show] if APP_CONFIG['anonymous_access']
load_and_authorize_resource

View File

@ -1,7 +1,7 @@
class Api::V1::ProjectsController < Api::V1::BaseController
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, only: [:get_id, :show, :refs_list] if APP_CONFIG['anonymous_access']
before_action :authenticate_user!
skip_before_action :authenticate_user!, only: [:get_id, :show, :refs_list] if APP_CONFIG['anonymous_access']
load_and_authorize_resource :project

View File

@ -1,8 +1,8 @@
class Api::V1::PullRequestsController < Api::V1::BaseController
respond_to :json
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, only: [:show, :index, :group_index, :commits, :files] if APP_CONFIG['anonymous_access']
before_action :authenticate_user!
skip_before_action :authenticate_user!, only: [:show, :index, :group_index, :commits, :files] if APP_CONFIG['anonymous_access']
load_resource :group, only: :group_index, find_by: :id, parent: false
load_resource :project

View File

@ -1,8 +1,8 @@
class Api::V1::RepositoriesController < Api::V1::BaseController
respond_to :csv, only: :packages
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, only: [:show, :projects] if APP_CONFIG['anonymous_access']
before_action :authenticate_user!
skip_before_action :authenticate_user!, only: [:show, :projects] if APP_CONFIG['anonymous_access']
load_and_authorize_resource :repository, through: :platform, shallow: true

View File

@ -1,5 +1,5 @@
class Api::V1::SearchController < Api::V1::BaseController
before_filter :authenticate_user! unless APP_CONFIG['anonymous_access']
before_action :authenticate_user! unless APP_CONFIG['anonymous_access']
def index
search = Search.new(params[:query], current_ability, paginate_params)

View File

@ -1,9 +1,9 @@
class Api::V1::UsersController < Api::V1::BaseController
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, only: [:show] if APP_CONFIG['anonymous_access']
before_action :authenticate_user!
skip_before_action :authenticate_user!, only: [:show] if APP_CONFIG['anonymous_access']
load_and_authorize_resource :user, only: :show
before_filter :set_current_user, except: :show
before_action :set_current_user, except: :show
def show
@user = User.opened.find params[:id] # dont show system users

View File

@ -9,12 +9,12 @@ class ApplicationController < ActionController::Base
layout :layout_by_resource
# Hack to prevent token auth on all pages except atom feed:
prepend_before_filter -> { redirect_to(new_user_session_path) if params[:token] && params[:token].is_a?(String) && params[:format] != 'atom'}
prepend_before_action -> { redirect_to(new_user_session_path) if params[:token] && params[:token].is_a?(String) && params[:format] != 'atom'}
before_filter :set_locale
before_filter -> { EventLog.current_controller = self },
before_action :set_locale
before_action -> { EventLog.current_controller = self },
only: [:create, :destroy, :open_id, :cancel, :publish, :change_visibility] # :update
after_filter -> { EventLog.current_controller = nil }
after_action -> { EventLog.current_controller = nil }
helper_method :get_owner

View File

@ -1,5 +1,5 @@
class AutocompletesController < ApplicationController
before_filter :authenticate_user!
before_action :authenticate_user!
def autocomplete_user_uname
results = User.opened.search(params[:query]).search_order.limit(5)

View File

@ -1,6 +1,6 @@
class Groups::BaseController < ApplicationController
before_filter :authenticate_user!
before_filter :find_group
before_action :authenticate_user!
before_action :find_group
protected

View File

@ -1,5 +1,5 @@
class Groups::MembersController < Groups::BaseController
before_filter -> { authorize! :manage_members, @group }
before_action -> { authorize! :manage_members, @group }
def index
@members = @group.members.order(:uname) - [@group.owner]

View File

@ -3,7 +3,7 @@ class Groups::ProfileController < Groups::BaseController
include PaginateHelper
load_and_authorize_resource class: Group, instance_name: 'group'
skip_before_filter :authenticate_user!, only: :show if APP_CONFIG['anonymous_access']
skip_before_action :authenticate_user!, only: :show if APP_CONFIG['anonymous_access']
def index
@groups = current_user.groups.paginate(page: params[:group_page]) # accessible_by(current_ability)

View File

@ -1,5 +1,5 @@
class HomeController < ApplicationController
before_filter :authenticate_user!, only: [:activity, :issues, :pull_requests]
before_action :authenticate_user!, only: [:activity, :issues, :pull_requests]
def root
render 'pages/tour/abf-tour-project-description-1'

View File

@ -1,8 +1,8 @@
class Platforms::ContentsController < Platforms::BaseController
include PaginateHelper
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, only: :index if APP_CONFIG['anonymous_access']
before_action :authenticate_user!
skip_before_action :authenticate_user!, only: :index if APP_CONFIG['anonymous_access']
load_and_authorize_resource :platform

View File

@ -1,5 +1,5 @@
class Platforms::KeyPairsController < Platforms::BaseController
before_filter :authenticate_user!
before_action :authenticate_user!
load_and_authorize_resource :platform
load_and_authorize_resource only: [:create, :destroy]

View File

@ -1,6 +1,6 @@
class Platforms::MaintainersController < ApplicationController
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, only: [:index] if APP_CONFIG['anonymous_access']
before_action :authenticate_user!
skip_before_action :authenticate_user!, only: [:index] if APP_CONFIG['anonymous_access']
load_and_authorize_resource :platform
def index

View File

@ -1,8 +1,8 @@
class Platforms::MassBuildsController < Platforms::BaseController
include DatatableHelper
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, only: [:index, :get_list] if APP_CONFIG['anonymous_access']
before_action :authenticate_user!
skip_before_action :authenticate_user!, only: [:index, :get_list] if APP_CONFIG['anonymous_access']
load_resource :platform
load_and_authorize_resource :through => :platform, :shallow => true

View File

@ -1,8 +1,8 @@
class Platforms::PlatformsController < Platforms::BaseController
include FileStoreHelper
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, only: [:advisories, :members, :show] if APP_CONFIG['anonymous_access']
before_action :authenticate_user!
skip_before_action :authenticate_user!, only: [:advisories, :members, :show] if APP_CONFIG['anonymous_access']
load_and_authorize_resource
def index

View File

@ -1,9 +1,9 @@
class Platforms::ProductBuildListsController < Platforms::BaseController
include FileStoreHelper
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, only: [:index, :show, :log] if APP_CONFIG['anonymous_access']
before_filter :redirect_to_full_path_if_short_url, only: [:show, :update]
before_action :authenticate_user!
skip_before_action :authenticate_user!, only: [:index, :show, :log] if APP_CONFIG['anonymous_access']
before_action :redirect_to_full_path_if_short_url, only: [:show, :update]
load_and_authorize_resource :platform, except: :index
load_and_authorize_resource :product, through: :platform, except: :index
load_and_authorize_resource :product_build_list, through: :product, except: :index

View File

@ -1,8 +1,8 @@
class Platforms::ProductsController < Platforms::BaseController
include GitHelper
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, only: [:index, :show] if APP_CONFIG['anonymous_access']
before_action :authenticate_user!
skip_before_action :authenticate_user!, only: [:index, :show] if APP_CONFIG['anonymous_access']
load_and_authorize_resource :platform
load_and_authorize_resource :product, through: :platform, except: :autocomplete_project

View File

@ -4,12 +4,12 @@ class Platforms::RepositoriesController < Platforms::BaseController
include RepositoriesHelper
include PaginateHelper
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, only: [:index, :show, :projects_list] if APP_CONFIG['anonymous_access']
before_action :authenticate_user!
skip_before_action :authenticate_user!, only: [:index, :show, :projects_list] if APP_CONFIG['anonymous_access']
load_and_authorize_resource :platform
load_and_authorize_resource :repository, through: :platform, shallow: true
before_filter :set_members, only: [:edit, :update]
before_action :set_members, only: [:edit, :update]
def index
@repositories = Repository.custom_sort(@repositories).paginate(page: current_page)

View File

@ -1,5 +1,5 @@
class Platforms::TokensController < Platforms::BaseController
before_filter :authenticate_user!
before_action :authenticate_user!
load_resource :platform
load_and_authorize_resource :through => :platform, :shallow => true

View File

@ -1,6 +1,6 @@
class Projects::BaseController < ApplicationController
prepend_before_filter :find_project
before_filter :init_statistics
prepend_before_action :find_project
before_action :init_statistics
protected

View File

@ -4,17 +4,17 @@ class Projects::BuildListsController < Projects::BaseController
NESTED_ACTIONS = [:index, :new, :create]
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, only: [:show, :index, :log] if APP_CONFIG['anonymous_access']
before_action :authenticate_user!
skip_before_action :authenticate_user!, only: [:show, :index, :log] if APP_CONFIG['anonymous_access']
before_filter :find_build_list, only: [:show, :publish, :cancel, :update, :log, :create_container, :dependent_projects]
before_action :find_build_list, only: [:show, :publish, :cancel, :update, :log, :create_container, :dependent_projects]
load_and_authorize_resource :project, only: [:new, :create]
load_resource :project, only: :index, parent: false
load_and_authorize_resource :build_list, through: :project, only: NESTED_ACTIONS, shallow: true
load_and_authorize_resource except: NESTED_ACTIONS
before_filter :create_from_build_list, only: :new
before_action :create_from_build_list, only: :new
def index
authorize!(:show, @project) if @project

View File

@ -1,12 +1,12 @@
class Projects::CollaboratorsController < Projects::BaseController
respond_to :html, :json
before_filter :authenticate_user!
before_action :authenticate_user!
load_resource :project
before_filter :authorize_collaborators
before_action :authorize_collaborators
before_filter :find_users
before_filter :find_groups
before_action :find_users
before_action :find_groups
def index
@collaborators = Collaborator.find_by_project(@project)

View File

@ -1,8 +1,8 @@
class Projects::CommentsController < Projects::BaseController
before_filter :authenticate_user!
before_action :authenticate_user!
load_and_authorize_resource :project
before_filter :find_commentable
before_filter :find_or_build_comment
before_action :find_commentable
before_action :find_or_build_comment
load_and_authorize_resource new: :new_line
include CommentsHelper

View File

@ -1,8 +1,8 @@
class Projects::CommitSubscribesController < Projects::BaseController
before_filter :authenticate_user!
before_action :authenticate_user!
load_and_authorize_resource :project
before_filter :find_commit
before_action :find_commit
def create
if Subscribe.subscribe_to_commit(@options)

View File

@ -1,13 +1,13 @@
class Projects::Git::BaseController < Projects::BaseController
before_filter :authenticate_user!
before_action :authenticate_user!
if APP_CONFIG['anonymous_access']
skip_before_filter :authenticate_user!, only: %i(show index blame raw archive diff tags branches)
before_filter :authenticate_user, only: %i(show index blame raw archive diff tags branches)
skip_before_action :authenticate_user!, only: %i(show index blame raw archive diff tags branches)
before_action :authenticate_user, only: %i(show index blame raw archive diff tags branches)
end
load_and_authorize_resource :project
before_filter :set_treeish_and_path
before_filter :set_branch_and_tree
before_action :set_treeish_and_path
before_action :set_branch_and_tree
protected

View File

@ -1,6 +1,6 @@
class Projects::Git::BlobsController < Projects::Git::BaseController
before_filter :set_blob
before_filter -> {authorize! :write, @project}, only: [:edit, :update]
before_action :set_blob
before_action -> {authorize! :write, @project}, only: [:edit, :update]
def show
end

View File

@ -1,5 +1,5 @@
class Projects::HooksController < Projects::BaseController
before_filter :authenticate_user!
before_action :authenticate_user!
load_and_authorize_resource :project
load_and_authorize_resource :hook, through: :project

View File

@ -1,11 +1,11 @@
class Projects::IssuesController < Projects::BaseController
NON_RESTFUL_ACTION = [:create_label, :update_label, :destroy_label]
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, only: [:index, :show] if APP_CONFIG['anonymous_access']
before_action :authenticate_user!
skip_before_action :authenticate_user!, only: [:index, :show] if APP_CONFIG['anonymous_access']
load_resource :project
load_and_authorize_resource :issue, through: :project, find_by: :serial_id, only: [:show, :edit, :update, :destroy, :new, :create, :index]
before_filter :load_and_authorize_label, only: NON_RESTFUL_ACTION
before_filter :find_collaborators, only: [:new, :create, :show, :search_collaborators]
before_action :load_and_authorize_label, only: NON_RESTFUL_ACTION
before_action :find_collaborators, only: [:new, :create, :show, :search_collaborators]
layout false, only: [:update, :search_collaborators]

View File

@ -2,9 +2,9 @@ class Projects::ProjectsController < Projects::BaseController
include DatatableHelper
include ProjectsHelper
before_filter :authenticate_user!
before_action :authenticate_user!
load_and_authorize_resource id_param: :name_with_owner # to force member actions load
before_filter :who_owns, only: [:new, :create, :mass_import, :run_mass_import]
before_action :who_owns, only: [:new, :create, :mass_import, :run_mass_import]
def index
@projects = Project.accessible_by(current_ability, :membered).search(params[:search])

View File

@ -1,11 +1,11 @@
class Projects::PullRequestsController < Projects::BaseController
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, only: [:index, :show] if APP_CONFIG['anonymous_access']
before_action :authenticate_user!
skip_before_action :authenticate_user!, only: [:index, :show] if APP_CONFIG['anonymous_access']
load_and_authorize_resource :project
load_resource :issue, through: :project, find_by: :serial_id, parent: false, except: [:index, :autocomplete_to_project]
load_and_authorize_resource instance_name: :pull, through: :issue, singleton: true, except: [:index, :autocomplete_to_project]
before_filter :find_collaborators, only: [:new, :create, :show]
before_action :find_collaborators, only: [:new, :create, :show]
def new
to_project = find_destination_project(false)

View File

@ -1,5 +1,5 @@
class Projects::SubscribesController < Projects::BaseController
before_filter :authenticate_user!
before_action :authenticate_user!
load_and_authorize_resource :project
load_and_authorize_resource :issue, through: :project, find_by: :serial_id

View File

@ -4,13 +4,13 @@ require 'cgi'
class Projects::WikiController < Projects::BaseController
WIKI_OPTIONS = {}
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, only: [:show, :index, :git, :compare, :compare_wiki, :history, :wiki_history, :search, :pages] if APP_CONFIG['anonymous_access']
before_action :authenticate_user!
skip_before_action :authenticate_user!, only: [:show, :index, :git, :compare, :compare_wiki, :history, :wiki_history, :search, :pages] if APP_CONFIG['anonymous_access']
load_resource :project
before_filter :authorize_read_actions, only: [:index, :show, :git, :compare, :compare_wiki, :history, :wiki_history, :search, :pages]
before_filter :authorize_write_actions, only: [:edit, :update, :new, :create, :destroy, :revert, :revert_wiki, :preview]
before_filter :get_wiki
before_action :authorize_read_actions, only: [:index, :show, :git, :compare, :compare_wiki, :history, :wiki_history, :search, :pages]
before_action :authorize_write_actions, only: [:edit, :update, :new, :create, :destroy, :revert, :revert_wiki, :preview]
before_action :get_wiki
def index
@name = 'Home'

View File

@ -1,7 +1,7 @@
class SearchController < ApplicationController
include PaginateHelper
before_filter :authenticate_user! unless APP_CONFIG['anonymous_access']
before_action :authenticate_user! unless APP_CONFIG['anonymous_access']
# load_and_authorize_resource
def index

View File

@ -1,6 +1,6 @@
class Users::BaseController < ApplicationController
before_filter :authenticate_user!
before_filter :find_user
before_action :authenticate_user!
before_action :find_user
protected

View File

@ -1,7 +1,7 @@
class Users::ProfileController < Users::BaseController
include PaginateHelper
skip_before_filter :authenticate_user!, only: :show if APP_CONFIG['anonymous_access']
skip_before_action :authenticate_user!, only: :show if APP_CONFIG['anonymous_access']
def show
respond_to do |format|

View File

@ -1,5 +1,5 @@
class Users::RegisterRequestsController < ApplicationController
before_filter :user_choose_locale
before_action :user_choose_locale
layout 'invite'
def new

View File

@ -1,5 +1,5 @@
class Users::RegistrationsController < Devise::RegistrationsController
before_filter :update_sanitized_params, if: :devise_controller?
before_action :update_sanitized_params, if: :devise_controller?
# POST /resource
def create

View File

@ -1,7 +1,7 @@
class Users::SettingsController < Users::BaseController
include AvatarHelper
before_filter :set_current_user
before_action :set_current_user
def profile
if request.patch?

View File

@ -1,5 +1,5 @@
class Users::SshKeysController < Users::BaseController
before_filter :set_current_user
before_action :set_current_user
def index
@ssh_key = SshKey.new

View File

@ -1,6 +1,6 @@
class Users::UsersController < Users::BaseController
skip_before_filter :authenticate_user!, only: [:allowed, :check, :discover]
before_filter :find_user_by_key, only: [:allowed, :discover]
skip_before_action :authenticate_user!, only: [:allowed, :check, :discover]
before_action :find_user_by_key, only: [:allowed, :discover]
def allowed
project = Project.find_by_owner_and_name! params[:project]