gearheads
/
mastodon
Archived
2
0
Fork 0

Create Settings::BaseController (#9507)

Define `Settings::BaseController#set_body_classes` so that sub classes
inherit `Settings::BaseController` don't need to define
`#set_body_classes` agein.
gh/stable
ysksn 2018-12-13 06:32:13 +09:00 committed by Eugen Rochko
parent 9983d21d35
commit b048926e67
14 changed files with 24 additions and 82 deletions

View File

@ -1,12 +1,11 @@
# frozen_string_literal: true # frozen_string_literal: true
class Settings::ApplicationsController < ApplicationController class Settings::ApplicationsController < Settings::BaseController
layout 'admin' layout 'admin'
before_action :authenticate_user! before_action :authenticate_user!
before_action :set_application, only: [:show, :update, :destroy, :regenerate] before_action :set_application, only: [:show, :update, :destroy, :regenerate]
before_action :prepare_scopes, only: [:create, :update] before_action :prepare_scopes, only: [:create, :update]
before_action :set_body_classes
def index def index
@applications = current_user.applications.order(id: :desc).page(params[:page]) @applications = current_user.applications.order(id: :desc).page(params[:page])
@ -70,8 +69,4 @@ class Settings::ApplicationsController < ApplicationController
scopes = params.fetch(:doorkeeper_application, {}).fetch(:scopes, nil) scopes = params.fetch(:doorkeeper_application, {}).fetch(:scopes, nil)
params[:doorkeeper_application][:scopes] = scopes.join(' ') if scopes.is_a? Array params[:doorkeeper_application][:scopes] = scopes.join(' ') if scopes.is_a? Array
end end
def set_body_classes
@body_classes = 'admin'
end
end end

View File

@ -0,0 +1,11 @@
# frozen_string_literal: true
class Settings::BaseController < ApplicationController
before_action :set_body_classes
private
def set_body_classes
@body_classes = 'admin'
end
end

View File

@ -1,11 +1,10 @@
# frozen_string_literal: true # frozen_string_literal: true
class Settings::DeletesController < ApplicationController class Settings::DeletesController < Settings::BaseController
layout 'admin' layout 'admin'
before_action :check_enabled_deletion before_action :check_enabled_deletion
before_action :authenticate_user! before_action :authenticate_user!
before_action :set_body_classes
def show def show
@confirmation = Form::DeleteConfirmation.new @confirmation = Form::DeleteConfirmation.new
@ -30,8 +29,4 @@ class Settings::DeletesController < ApplicationController
def delete_params def delete_params
params.require(:form_delete_confirmation).permit(:password) params.require(:form_delete_confirmation).permit(:password)
end end
def set_body_classes
@body_classes = 'admin'
end
end end

View File

@ -1,12 +1,11 @@
# frozen_string_literal: true # frozen_string_literal: true
class Settings::ExportsController < ApplicationController class Settings::ExportsController < Settings::BaseController
include Authorization include Authorization
layout 'admin' layout 'admin'
before_action :authenticate_user! before_action :authenticate_user!
before_action :set_body_classes
def show def show
@export = Export.new(current_account) @export = Export.new(current_account)
@ -21,10 +20,4 @@ class Settings::ExportsController < ApplicationController
redirect_to settings_export_path redirect_to settings_export_path
end end
private
def set_body_classes
@body_classes = 'admin'
end
end end

View File

@ -1,10 +1,9 @@
# frozen_string_literal: true # frozen_string_literal: true
class Settings::FollowerDomainsController < ApplicationController class Settings::FollowerDomainsController < Settings::BaseController
layout 'admin' layout 'admin'
before_action :authenticate_user! before_action :authenticate_user!
before_action :set_body_classes
def show def show
@account = current_account @account = current_account
@ -26,8 +25,4 @@ class Settings::FollowerDomainsController < ApplicationController
def bulk_params def bulk_params
params.permit(select: []) params.permit(select: [])
end end
def set_body_classes
@body_classes = 'admin'
end
end end

View File

@ -1,11 +1,10 @@
# frozen_string_literal: true # frozen_string_literal: true
class Settings::ImportsController < ApplicationController class Settings::ImportsController < Settings::BaseController
layout 'admin' layout 'admin'
before_action :authenticate_user! before_action :authenticate_user!
before_action :set_account before_action :set_account
before_action :set_body_classes
def show def show
@import = Import.new @import = Import.new
@ -32,8 +31,4 @@ class Settings::ImportsController < ApplicationController
def import_params def import_params
params.require(:import).permit(:data, :type) params.require(:import).permit(:data, :type)
end end
def set_body_classes
@body_classes = 'admin'
end
end end

View File

@ -1,10 +1,9 @@
# frozen_string_literal: true # frozen_string_literal: true
class Settings::MigrationsController < ApplicationController class Settings::MigrationsController < Settings::BaseController
layout 'admin' layout 'admin'
before_action :authenticate_user! before_action :authenticate_user!
before_action :set_body_classes
def show def show
@migration = Form::Migration.new(account: current_account.moved_to_account) @migration = Form::Migration.new(account: current_account.moved_to_account)
@ -32,8 +31,4 @@ class Settings::MigrationsController < ApplicationController
current_account.moved_to_account_id != @migration.account&.id && current_account.moved_to_account_id != @migration.account&.id &&
current_account.id != @migration.account&.id current_account.id != @migration.account&.id
end end
def set_body_classes
@body_classes = 'admin'
end
end end

View File

@ -1,10 +1,9 @@
# frozen_string_literal: true # frozen_string_literal: true
class Settings::NotificationsController < ApplicationController class Settings::NotificationsController < Settings::BaseController
layout 'admin' layout 'admin'
before_action :authenticate_user! before_action :authenticate_user!
before_action :set_body_classes
def show; end def show; end
@ -30,8 +29,4 @@ class Settings::NotificationsController < ApplicationController
interactions: %i(must_be_follower must_be_following must_be_following_dm) interactions: %i(must_be_follower must_be_following must_be_following_dm)
) )
end end
def set_body_classes
@body_classes = 'admin'
end
end end

View File

@ -1,10 +1,9 @@
# frozen_string_literal: true # frozen_string_literal: true
class Settings::PreferencesController < ApplicationController class Settings::PreferencesController < Settings::BaseController
layout 'admin' layout 'admin'
before_action :authenticate_user! before_action :authenticate_user!
before_action :set_body_classes
def show; end def show; end
@ -53,8 +52,4 @@ class Settings::PreferencesController < ApplicationController
interactions: %i(must_be_follower must_be_following) interactions: %i(must_be_follower must_be_following)
) )
end end
def set_body_classes
@body_classes = 'admin'
end
end end

View File

@ -1,13 +1,12 @@
# frozen_string_literal: true # frozen_string_literal: true
class Settings::ProfilesController < ApplicationController class Settings::ProfilesController < Settings::BaseController
include ObfuscateFilename include ObfuscateFilename
layout 'admin' layout 'admin'
before_action :authenticate_user! before_action :authenticate_user!
before_action :set_account before_action :set_account
before_action :set_body_classes
obfuscate_filename [:account, :avatar] obfuscate_filename [:account, :avatar]
obfuscate_filename [:account, :header] obfuscate_filename [:account, :header]
@ -35,8 +34,4 @@ class Settings::ProfilesController < ApplicationController
def set_account def set_account
@account = current_user.account @account = current_user.account
end end
def set_body_classes
@body_classes = 'admin'
end
end end

View File

@ -1,8 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
class Settings::SessionsController < ApplicationController class Settings::SessionsController < Settings::BaseController
before_action :set_session, only: :destroy before_action :set_session, only: :destroy
before_action :set_body_classes
def destroy def destroy
@session.destroy! @session.destroy!
@ -15,8 +14,4 @@ class Settings::SessionsController < ApplicationController
def set_session def set_session
@session = current_user.session_activations.find(params[:id]) @session = current_user.session_activations.find(params[:id])
end end
def set_body_classes
@body_classes = 'admin'
end
end end

View File

@ -2,12 +2,11 @@
module Settings module Settings
module TwoFactorAuthentication module TwoFactorAuthentication
class ConfirmationsController < ApplicationController class ConfirmationsController < BaseController
layout 'admin' layout 'admin'
before_action :authenticate_user! before_action :authenticate_user!
before_action :ensure_otp_secret before_action :ensure_otp_secret
before_action :set_body_classes
def new def new
prepare_two_factor_form prepare_two_factor_form
@ -44,10 +43,6 @@ module Settings
def ensure_otp_secret def ensure_otp_secret
redirect_to settings_two_factor_authentication_path unless current_user.otp_secret redirect_to settings_two_factor_authentication_path unless current_user.otp_secret
end end
def set_body_classes
@body_classes = 'admin'
end
end end
end end
end end

View File

@ -2,11 +2,10 @@
module Settings module Settings
module TwoFactorAuthentication module TwoFactorAuthentication
class RecoveryCodesController < ApplicationController class RecoveryCodesController < BaseController
layout 'admin' layout 'admin'
before_action :authenticate_user! before_action :authenticate_user!
before_action :set_body_classes
def create def create
@recovery_codes = current_user.generate_otp_backup_codes! @recovery_codes = current_user.generate_otp_backup_codes!
@ -14,12 +13,6 @@ module Settings
flash[:notice] = I18n.t('two_factor_authentication.recovery_codes_regenerated') flash[:notice] = I18n.t('two_factor_authentication.recovery_codes_regenerated')
render :index render :index
end end
private
def set_body_classes
@body_classes = 'admin'
end
end end
end end
end end

View File

@ -1,12 +1,11 @@
# frozen_string_literal: true # frozen_string_literal: true
module Settings module Settings
class TwoFactorAuthenticationsController < ApplicationController class TwoFactorAuthenticationsController < BaseController
layout 'admin' layout 'admin'
before_action :authenticate_user! before_action :authenticate_user!
before_action :verify_otp_required, only: [:create] before_action :verify_otp_required, only: [:create]
before_action :set_body_classes
def show def show
@confirmation = Form::TwoFactorConfirmation.new @confirmation = Form::TwoFactorConfirmation.new
@ -44,9 +43,5 @@ module Settings
current_user.validate_and_consume_otp!(confirmation_params[:code]) || current_user.validate_and_consume_otp!(confirmation_params[:code]) ||
current_user.invalidate_otp_backup_code!(confirmation_params[:code]) current_user.invalidate_otp_backup_code!(confirmation_params[:code])
end end
def set_body_classes
@body_classes = 'admin'
end
end end
end end