mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-06 09:51:24 +00:00
Use before action to set up i-var in create action
This commit is contained in:
parent
3b087708a7
commit
db2930a46f
|
@ -3,8 +3,8 @@
|
|||
module Admin
|
||||
class DomainBlocksController < BaseController
|
||||
before_action :set_domain_block, only: [:destroy, :edit, :update]
|
||||
|
||||
before_action :authorize_domain_block_create, only: [:batch, :new, :create]
|
||||
before_action :populate_domain_block_from_params, only: :create
|
||||
|
||||
PERMITTED_PARAMS = %i(
|
||||
domain
|
||||
|
@ -40,8 +40,6 @@ module Admin
|
|||
end
|
||||
|
||||
def create
|
||||
@domain_block = DomainBlock.new(resource_params)
|
||||
|
||||
# Disallow accidentally downgrading a domain block
|
||||
if existing_domain_block.present? && !@domain_block.stricter_than?(existing_domain_block)
|
||||
@domain_block.validate
|
||||
|
@ -98,6 +96,10 @@ module Admin
|
|||
authorize :domain_block, :create?
|
||||
end
|
||||
|
||||
def populate_domain_block_from_params
|
||||
@domain_block = DomainBlock.new(resource_params)
|
||||
end
|
||||
|
||||
def existing_domain_block
|
||||
@existing_domain_block ||= DomainBlock.rule_for(resource_params[:domain]) if resource_params[:domain].present?
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user