about summary refs log tree commit diff
path: root/app/controllers/admin/domain_blocks_controller.rb
blob: 1f443284784ba012df896d240657e03d58fcd84d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# frozen_string_literal: true

class Admin::DomainBlocksController < ApplicationController
  before_action :require_admin!

  layout 'admin'

  def index
    @blocks = DomainBlock.paginate(page: params[:page], per_page: 40)
  end

  def new
    @domain_block = DomainBlock.new
  end

  def create
    @domain_block = DomainBlock.new(resource_params)

    if @domain_block.save
      DomainBlockWorker.perform_async(@domain_block.id)
      redirect_to admin_domain_blocks_path, notice: 'Domain block is now being processed'
    else
      render action: :new
    end
  end

  private

  def resource_params
    params.require(:domain_block).permit(:domain, :severity)
  end
end