2016-12-13 12:42:10 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-04-10 19:27:03 +00:00
|
|
|
module Admin
|
|
|
|
class DomainBlocksController < BaseController
|
|
|
|
def index
|
2017-04-10 23:11:41 +00:00
|
|
|
@blocks = DomainBlock.page(params[:page])
|
2017-04-10 19:27:03 +00:00
|
|
|
end
|
2016-12-13 12:42:10 +00:00
|
|
|
|
2017-04-10 19:27:03 +00:00
|
|
|
def new
|
|
|
|
@domain_block = DomainBlock.new
|
|
|
|
end
|
2017-04-03 16:55:06 +00:00
|
|
|
|
2017-04-10 19:27:03 +00:00
|
|
|
def create
|
|
|
|
@domain_block = DomainBlock.new(resource_params)
|
2017-04-03 16:55:06 +00:00
|
|
|
|
2017-04-10 19:27:03 +00:00
|
|
|
if @domain_block.save
|
|
|
|
DomainBlockWorker.perform_async(@domain_block.id)
|
2017-04-16 17:37:01 +00:00
|
|
|
redirect_to admin_domain_blocks_path, notice: I18n.t('admin.domain_blocks.created_msg')
|
2017-04-10 19:27:03 +00:00
|
|
|
else
|
2017-04-19 13:37:42 +00:00
|
|
|
render :new
|
2017-04-10 19:27:03 +00:00
|
|
|
end
|
2017-04-03 16:55:06 +00:00
|
|
|
end
|
|
|
|
|
2017-04-16 10:51:30 +00:00
|
|
|
def show
|
|
|
|
@domain_block = DomainBlock.find(params[:id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@domain_block = DomainBlock.find(params[:id])
|
2017-04-29 22:25:38 +00:00
|
|
|
UnblockDomainService.new.call(@domain_block, retroactive_unblock?)
|
2017-04-16 17:37:01 +00:00
|
|
|
redirect_to admin_domain_blocks_path, notice: I18n.t('admin.domain_blocks.destroyed_msg')
|
2017-04-16 10:51:30 +00:00
|
|
|
end
|
|
|
|
|
2017-04-10 19:27:03 +00:00
|
|
|
private
|
2017-04-03 16:55:06 +00:00
|
|
|
|
2017-04-10 19:27:03 +00:00
|
|
|
def resource_params
|
2017-04-16 10:51:30 +00:00
|
|
|
params.require(:domain_block).permit(:domain, :severity, :reject_media, :retroactive)
|
2017-04-10 19:27:03 +00:00
|
|
|
end
|
2017-04-29 22:25:38 +00:00
|
|
|
|
|
|
|
def retroactive_unblock?
|
|
|
|
resource_params[:retroactive] == '1'
|
|
|
|
end
|
2016-12-13 12:42:10 +00:00
|
|
|
end
|
|
|
|
end
|