Commit 39f9af8a authored by jplang's avatar jplang

Use .before_action instead of .before_filter.

git-svn-id: https://svn.redmine.org/redmine/trunk@15655 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent f9c87101
......@@ -17,7 +17,7 @@
class ActivitiesController < ApplicationController
menu_item :activity
before_filter :find_optional_project
before_action :find_optional_project
accept_rss_auth :index
def index
......
......@@ -21,7 +21,7 @@ class AdminController < ApplicationController
menu_item :plugins, :only => :plugins
menu_item :info, :only => :info
before_filter :require_admin
before_action :require_admin
helper :sort
include SortHelper
......
......@@ -51,7 +51,7 @@ class ApplicationController < ActionController::Base
end
end
before_filter :session_expiration, :user_setup, :check_if_login_required, :check_password_change, :set_localization
before_action :session_expiration, :user_setup, :check_if_login_required, :check_password_change, :set_localization
rescue_from ::Unauthorized, :with => :deny_access
rescue_from ::ActionView::MissingTemplate, :with => :missing_template
......@@ -369,7 +369,7 @@ class ApplicationController < ActionController::Base
end
# make sure that the user is a member of the project (or admin) if project is private
# used as a before_filter for actions that do not require any particular permission on the project
# used as a before_action for actions that do not require any particular permission on the project
def check_project_privacy
if @project && !@project.archived?
if @project.visible?
......
......@@ -16,11 +16,11 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class AttachmentsController < ApplicationController
before_filter :find_attachment, :only => [:show, :download, :thumbnail, :destroy]
before_filter :find_editable_attachments, :only => [:edit, :update]
before_filter :file_readable, :read_authorize, :only => [:show, :download, :thumbnail]
before_filter :delete_authorize, :only => :destroy
before_filter :authorize_global, :only => :upload
before_action :find_attachment, :only => [:show, :download, :thumbnail, :destroy]
before_action :find_editable_attachments, :only => [:edit, :update]
before_action :file_readable, :read_authorize, :only => [:show, :download, :thumbnail]
before_action :delete_authorize, :only => :destroy
before_action :authorize_global, :only => :upload
accept_api_auth :show, :download, :thumbnail, :upload, :destroy
......
......@@ -19,8 +19,8 @@ class AuthSourcesController < ApplicationController
layout 'admin'
menu_item :ldap_authentication
before_filter :require_admin
before_filter :find_auth_source, :only => [:edit, :update, :test_connection, :destroy]
before_action :require_admin
before_action :find_auth_source, :only => [:edit, :update, :test_connection, :destroy]
require_sudo_mode :update, :destroy
def index
......
......@@ -16,7 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class AutoCompletesController < ApplicationController
before_filter :find_project
before_action :find_project
def issues
@issues = []
......
......@@ -17,7 +17,7 @@
class BoardsController < ApplicationController
default_search_scope :messages
before_filter :find_project_by_project_id, :find_board_if_available, :authorize
before_action :find_project_by_project_id, :find_board_if_available, :authorize
accept_rss_auth :index, :show
helper :sort
......
......@@ -17,7 +17,7 @@
class CalendarsController < ApplicationController
menu_item :calendar
before_filter :find_optional_project
before_action :find_optional_project
rescue_from Query::StatementInvalid, :with => :query_statement_invalid
......
......@@ -18,9 +18,9 @@
class CommentsController < ApplicationController
default_search_scope :news
model_object News
before_filter :find_model_object
before_filter :find_project_from_association
before_filter :authorize
before_action :find_model_object
before_action :find_project_from_association
before_action :authorize
def create
raise Unauthorized unless @news.commentable?
......
......@@ -19,7 +19,7 @@ class ContextMenusController < ApplicationController
helper :watchers
helper :issues
before_filter :find_issues, :only => :issues
before_action :find_issues, :only => :issues
def issues
if (@issues.size == 1)
......
......@@ -18,9 +18,9 @@
class CustomFieldEnumerationsController < ApplicationController
layout 'admin'
before_filter :require_admin
before_filter :find_custom_field
before_filter :find_enumeration, :only => :destroy
before_action :require_admin
before_action :find_custom_field
before_action :find_enumeration, :only => :destroy
helper :custom_fields
......
......@@ -18,9 +18,9 @@
class CustomFieldsController < ApplicationController
layout 'admin'
before_filter :require_admin
before_filter :build_new_custom_field, :only => [:new, :create]
before_filter :find_custom_field, :only => [:edit, :update, :destroy]
before_action :require_admin
before_action :build_new_custom_field, :only => [:new, :create]
before_action :find_custom_field, :only => [:edit, :update, :destroy]
accept_api_auth :index
def index
......
......@@ -18,10 +18,10 @@
class DocumentsController < ApplicationController
default_search_scope :documents
model_object Document
before_filter :find_project_by_project_id, :only => [:index, :new, :create]
before_filter :find_model_object, :except => [:index, :new, :create]
before_filter :find_project_from_association, :except => [:index, :new, :create]
before_filter :authorize
before_action :find_project_by_project_id, :only => [:index, :new, :create]
before_action :find_model_object, :except => [:index, :new, :create]
before_action :find_project_from_association, :except => [:index, :new, :create]
before_action :authorize
helper :attachments
helper :custom_fields
......
......@@ -16,8 +16,8 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class EmailAddressesController < ApplicationController
before_filter :find_user, :require_admin_or_current_user
before_filter :find_email_address, :only => [:update, :destroy]
before_action :find_user, :require_admin_or_current_user
before_action :find_email_address, :only => [:update, :destroy]
require_sudo_mode :create, :update, :destroy
def index
......
......@@ -18,10 +18,10 @@
class EnumerationsController < ApplicationController
layout 'admin'
before_filter :require_admin, :except => :index
before_filter :require_admin_or_api_request, :only => :index
before_filter :build_new_enumeration, :only => [:new, :create]
before_filter :find_enumeration, :only => [:edit, :update, :destroy]
before_action :require_admin, :except => :index
before_action :require_admin_or_api_request, :only => :index
before_action :build_new_enumeration, :only => [:new, :create]
before_action :find_enumeration, :only => [:edit, :update, :destroy]
accept_api_auth :index
helper :custom_fields
......
......@@ -18,8 +18,8 @@
class FilesController < ApplicationController
menu_item :files
before_filter :find_project_by_project_id
before_filter :authorize
before_action :find_project_by_project_id
before_action :authorize
helper :sort
include SortHelper
......
......@@ -17,7 +17,7 @@
class GanttsController < ApplicationController
menu_item :gantt
before_filter :find_optional_project
before_action :find_optional_project
rescue_from Query::StatementInvalid, :with => :query_statement_invalid
......
......@@ -18,8 +18,8 @@
class GroupsController < ApplicationController
layout 'admin'
before_filter :require_admin
before_filter :find_group, :except => [:index, :new, :create]
before_action :require_admin
before_action :find_group, :except => [:index, :new, :create]
accept_api_auth :index, :show, :create, :update, :destroy, :add_users, :remove_user
require_sudo_mode :add_users, :remove_user, :create, :update, :destroy, :edit_membership, :destroy_membership
......
......@@ -19,8 +19,8 @@ require 'csv'
class ImportsController < ApplicationController
before_filter :find_import, :only => [:show, :settings, :mapping, :run]
before_filter :authorize_global
before_action :find_import, :only => [:show, :settings, :mapping, :run]
before_action :authorize_global
helper :issues
helper :queries
......
......@@ -18,10 +18,10 @@
class IssueCategoriesController < ApplicationController
menu_item :settings
model_object IssueCategory
before_filter :find_model_object, :except => [:index, :new, :create]
before_filter :find_project_from_association, :except => [:index, :new, :create]
before_filter :find_project_by_project_id, :only => [:index, :new, :create]
before_filter :authorize
before_action :find_model_object, :except => [:index, :new, :create]
before_action :find_project_from_association, :except => [:index, :new, :create]
before_action :find_project_by_project_id, :only => [:index, :new, :create]
before_action :authorize
accept_api_auth :index, :show, :create, :update, :destroy
def index
......
......@@ -16,8 +16,8 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class IssueRelationsController < ApplicationController
before_filter :find_issue, :authorize, :only => [:index, :create]
before_filter :find_relation, :only => [:show, :destroy]
before_action :find_issue, :authorize, :only => [:index, :create]
before_action :find_relation, :only => [:show, :destroy]
accept_api_auth :index, :show, :create, :destroy
......
......@@ -18,8 +18,8 @@
class IssueStatusesController < ApplicationController
layout 'admin'
before_filter :require_admin, :except => :index
before_filter :require_admin_or_api_request, :only => :index
before_action :require_admin, :except => :index
before_action :require_admin_or_api_request, :only => :index
accept_api_auth :index
def index
......
......@@ -18,11 +18,11 @@
class IssuesController < ApplicationController
default_search_scope :issues
before_filter :find_issue, :only => [:show, :edit, :update]
before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :destroy]
before_filter :authorize, :except => [:index, :new, :create]
before_filter :find_optional_project, :only => [:index, :new, :create]
before_filter :build_new_issue_from_params, :only => [:new, :create]
before_action :find_issue, :only => [:show, :edit, :update]
before_action :find_issues, :only => [:bulk_edit, :bulk_update, :destroy]
before_action :authorize, :except => [:index, :new, :create]
before_action :find_optional_project, :only => [:index, :new, :create]
before_action :build_new_issue_from_params, :only => [:new, :create]
accept_rss_auth :index, :show
accept_api_auth :index, :show, :create, :update, :destroy
......
......@@ -16,10 +16,10 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class JournalsController < ApplicationController
before_filter :find_journal, :only => [:edit, :update, :diff]
before_filter :find_issue, :only => [:new]
before_filter :find_optional_project, :only => [:index]
before_filter :authorize, :only => [:new, :edit, :update, :diff]
before_action :find_journal, :only => [:edit, :update, :diff]
before_action :find_issue, :only => [:new]
before_action :find_optional_project, :only => [:index]
before_action :authorize, :only => [:new, :edit, :update, :diff]
accept_rss_auth :index
menu_item :issues
......
......@@ -16,7 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class MailHandlerController < ActionController::Base
before_filter :check_credential
before_action :check_credential
# Displays the email submission form
def new
......
......@@ -17,10 +17,10 @@
class MembersController < ApplicationController
model_object Member
before_filter :find_model_object, :except => [:index, :new, :create, :autocomplete]
before_filter :find_project_from_association, :except => [:index, :new, :create, :autocomplete]
before_filter :find_project_by_project_id, :only => [:index, :new, :create, :autocomplete]
before_filter :authorize
before_action :find_model_object, :except => [:index, :new, :create, :autocomplete]
before_action :find_project_from_association, :except => [:index, :new, :create, :autocomplete]
before_action :find_project_by_project_id, :only => [:index, :new, :create, :autocomplete]
before_action :authorize
accept_api_auth :index, :show, :create, :update, :destroy
require_sudo_mode :create, :update, :destroy
......
......@@ -18,10 +18,10 @@
class MessagesController < ApplicationController
menu_item :boards
default_search_scope :messages
before_filter :find_board, :only => [:new, :preview]
before_filter :find_attachments, :only => [:preview]
before_filter :find_message, :except => [:new, :preview]
before_filter :authorize, :except => [:preview, :edit, :destroy]
before_action :find_board, :only => [:new, :preview]
before_action :find_attachments, :only => [:preview]
before_action :find_message, :except => [:new, :preview]
before_action :authorize, :except => [:preview, :edit, :destroy]
helper :boards
helper :watchers
......
......@@ -16,7 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class MyController < ApplicationController
before_filter :require_login
before_action :require_login
# let user change user's password when user has to
skip_before_filter :check_password_change, :only => :password
......
......@@ -18,11 +18,11 @@
class NewsController < ApplicationController
default_search_scope :news
model_object News
before_filter :find_model_object, :except => [:new, :create, :index]
before_filter :find_project_from_association, :except => [:new, :create, :index]
before_filter :find_project_by_project_id, :only => [:new, :create]
before_filter :authorize, :except => [:index]
before_filter :find_optional_project, :only => :index
before_action :find_model_object, :except => [:new, :create, :index]
before_action :find_project_from_association, :except => [:new, :create, :index]
before_action :find_project_by_project_id, :only => [:new, :create]
before_action :authorize, :except => [:index]
before_action :find_optional_project, :only => :index
accept_rss_auth :index
accept_api_auth :index
......
......@@ -16,7 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class PreviewsController < ApplicationController
before_filter :find_project, :find_attachments
before_action :find_project, :find_attachments
def issue
@issue = Issue.visible.find_by_id(params[:id]) unless params[:id].blank?
......
......@@ -18,9 +18,9 @@
class PrincipalMembershipsController < ApplicationController
layout 'admin'
before_filter :require_admin
before_filter :find_principal, :only => [:new, :create]
before_filter :find_membership, :only => [:update, :destroy]
before_action :require_admin
before_action :find_principal, :only => [:new, :create]
before_action :find_membership, :only => [:update, :destroy]
def new
@projects = Project.active.all
......
......@@ -16,8 +16,8 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class ProjectEnumerationsController < ApplicationController
before_filter :find_project_by_project_id
before_filter :authorize
before_action :find_project_by_project_id
before_action :authorize
def update
if params[:enumerations]
......
......@@ -19,10 +19,10 @@ class ProjectsController < ApplicationController
menu_item :overview
menu_item :settings, :only => :settings
before_filter :find_project, :except => [ :index, :list, :new, :create, :copy ]
before_filter :authorize, :except => [ :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy]
before_filter :authorize_global, :only => [:new, :create]
before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ]
before_action :find_project, :except => [ :index, :list, :new, :create, :copy ]
before_action :authorize, :except => [ :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy]
before_action :authorize_global, :only => [:new, :create]
before_action :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ]
accept_rss_auth :index
accept_api_auth :index, :show, :create, :update, :destroy
require_sudo_mode :destroy
......
......@@ -17,8 +17,8 @@
class QueriesController < ApplicationController
menu_item :issues
before_filter :find_query, :except => [:new, :create, :index]
before_filter :find_optional_project, :only => [:new, :create]
before_action :find_query, :except => [:new, :create, :index]
before_action :find_optional_project, :only => [:new, :create]
accept_api_auth :index
......
......@@ -17,7 +17,7 @@
class ReportsController < ApplicationController
menu_item :issues
before_filter :find_project, :authorize, :find_issue_statuses
before_action :find_project, :authorize, :find_issue_statuses
def issue_report
@trackers = @project.rolled_up_trackers(false).visible
......
......@@ -28,11 +28,11 @@ class RepositoriesController < ApplicationController
menu_item :settings, :only => [:new, :create, :edit, :update, :destroy, :committers]
default_search_scope :changesets
before_filter :find_project_by_project_id, :only => [:new, :create]
before_filter :find_repository, :only => [:edit, :update, :destroy, :committers]
before_filter :find_project_repository, :except => [:new, :create, :edit, :update, :destroy, :committers]
before_filter :find_changeset, :only => [:revision, :add_related_issue, :remove_related_issue]
before_filter :authorize
before_action :find_project_by_project_id, :only => [:new, :create]
before_action :find_repository, :only => [:edit, :update, :destroy, :committers]
before_action :find_project_repository, :except => [:new, :create, :edit, :update, :destroy, :committers]
before_action :find_changeset, :only => [:revision, :add_related_issue, :remove_related_issue]
before_action :authorize
accept_rss_auth :revisions
rescue_from Redmine::Scm::Adapters::CommandFailed, :with => :show_error_command_failed
......
......@@ -18,9 +18,9 @@
class RolesController < ApplicationController
layout 'admin'
before_filter :require_admin, :except => [:index, :show]
before_filter :require_admin_or_api_request, :only => [:index, :show]
before_filter :find_role, :only => [:show, :edit, :update, :destroy]
before_action :require_admin, :except => [:index, :show]
before_action :require_admin_or_api_request, :only => [:index, :show]
before_action :find_role, :only => [:show, :edit, :update, :destroy]
accept_api_auth :index, :show
require_sudo_mode :create, :update, :destroy
......
......@@ -16,7 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class SearchController < ApplicationController
before_filter :find_optional_project
before_action :find_optional_project
accept_api_auth :index
def index
......
......@@ -21,7 +21,7 @@ class SettingsController < ApplicationController
helper :queries
before_filter :require_admin
before_action :require_admin
require_sudo_mode :index, :edit, :plugin
......
......@@ -16,7 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class SysController < ActionController::Base
before_filter :check_enabled
before_action :check_enabled
def projects
p = Project.active.has_module(:repository).
......
......@@ -18,13 +18,13 @@
class TimelogController < ApplicationController
menu_item :issues
before_filter :find_time_entry, :only => [:show, :edit, :update]
before_filter :find_time_entries, :only => [:bulk_edit, :bulk_update, :destroy]
before_filter :authorize, :only => [:show, :edit, :update, :bulk_edit, :bulk_update, :destroy]
before_action :find_time_entry, :only => [:show, :edit, :update]
before_action :find_time_entries, :only => [:bulk_edit, :bulk_update, :destroy]
before_action :authorize, :only => [:show, :edit, :update, :bulk_edit, :bulk_update, :destroy]
before_filter :find_optional_issue, :only => [:new, :create]
before_filter :find_optional_project, :only => [:index, :report]
before_filter :authorize_global, :only => [:new, :create, :index, :report]
before_action :find_optional_issue, :only => [:new, :create]
before_action :find_optional_project, :only => [:index, :report]
before_action :authorize_global, :only => [:new, :create, :index, :report]
accept_rss_auth :index
accept_api_auth :index, :show, :create, :update, :destroy
......
......@@ -18,8 +18,8 @@
class TrackersController < ApplicationController
layout 'admin'
before_filter :require_admin, :except => :index
before_filter :require_admin_or_api_request, :only => :index
before_action :require_admin, :except => :index
before_action :require_admin_or_api_request, :only => :index
accept_api_auth :index
def index
......
......@@ -18,8 +18,8 @@
class UsersController < ApplicationController
layout 'admin'
before_filter :require_admin, :except => :show
before_filter :find_user, :only => [:show, :edit, :update, :destroy]
before_action :require_admin, :except => :show
before_action :find_user, :only => [:show, :edit, :update, :destroy]
accept_api_auth :index, :show, :create, :update, :destroy
helper :sort
......
......@@ -18,10 +18,10 @@
class VersionsController < ApplicationController
menu_item :roadmap
model_object Version
before_filter :find_model_object, :except => [:index, :new, :create, :close_completed]
before_filter :find_project_from_association, :except => [:index, :new, :create, :close_completed]
before_filter :find_project_by_project_id, :only => [:index, :new, :create, :close_completed]
before_filter :authorize
before_action :find_model_object, :except => [:index, :new, :create, :close_completed]
before_action :find_project_from_association, :except => [:index, :new, :create, :close_completed]
before_action :find_project_by_project_id, :only => [:index, :new, :create, :close_completed]
before_action :authorize
accept_api_auth :index, :show, :create, :update, :destroy
......
......@@ -16,7 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class WatchersController < ApplicationController
before_filter :require_login, :find_watchables, :only => [:watch, :unwatch]
before_action :require_login, :find_watchables, :only => [:watch, :unwatch]
def watch
set_watcher(@watchables, User.current, true)
......@@ -26,7 +26,7 @@ class WatchersController < ApplicationController
set_watcher(@watchables, User.current, false)
end
before_filter :find_project, :authorize, :only => [:new, :create, :append, :destroy, :autocomplete_for_user]
before_action :find_project, :authorize, :only => [:new, :create, :append, :destroy, :autocomplete_for_user]
accept_api_auth :create, :destroy
def new
......
......@@ -31,11 +31,11 @@
# TODO: still being worked on
class WikiController < ApplicationController
default_search_scope :wiki_pages
before_filter :find_wiki, :authorize
before_filter :find_existing_or_new_page, :only => [:show, :edit, :update]
before_filter :find_existing_page, :only => [:rename, :protect, :history, :diff, :annotate, :add_attachment, :destroy, :destroy_version]
before_action :find_wiki, :authorize
before_action :find_existing_or_new_page, :only => [:show, :edit, :update]
before_action :find_existing_page, :only => [:rename, :protect, :history, :diff, :annotate, :add_attachment, :destroy, :destroy_version]
before_action :find_attachments, :only => [:preview]
accept_api_auth :index, :show, :update, :destroy
before_filter :find_attachments, :only => [:preview]
helper :attachments
include AttachmentsHelper
......
......@@ -17,7 +17,7 @@
class WikisController < ApplicationController
menu_item :settings
before_filter :find_project, :authorize
before_action :find_project, :authorize
# Create or update a project's wiki
def edit
......
......@@ -18,7 +18,7 @@
class WorkflowsController < ApplicationController
layout 'admin'
before_filter :require_admin
before_action :require_admin
def index
@roles = Role.sorted.select(&:consider_workflow?)
......
......@@ -3,7 +3,7 @@ class ExampleController < ApplicationController
unloadable
layout 'base'
before_filter :find_project, :authorize
before_action :find_project, :authorize
menu_item :sample_plugin
def say_hello
......
......@@ -108,7 +108,7 @@ module Redmine
@sudo_form ||= SudoMode::Form.new
@sudo_form.original_fields = params.slice( *param_names )
# a simple 'render "sudo_mode/new"' works when used directly inside an
# action, but not when called from a before_filter:
# action, but not when called from a before_action:
respond_to do |format|
format.html { render 'sudo_mode/new' }
format.js { render 'sudo_mode/new' }
......@@ -168,7 +168,7 @@ module Redmine
actions = args.dup
options = actions.extract_options!
filter = SudoRequestFilter.new Array(options[:parameters]), Array(options[:only])
before_filter filter, only: actions
before_action filter, only: actions
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment