mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Create white ips
This commit is contained in:
parent
254849494f
commit
8e37355e13
15 changed files with 246 additions and 3 deletions
56
app/controllers/admin/white_ips_controller.rb
Normal file
56
app/controllers/admin/white_ips_controller.rb
Normal file
|
@ -0,0 +1,56 @@
|
|||
class Admin::WhiteIpsController < AdminController
|
||||
load_and_authorize_resource
|
||||
|
||||
before_action :set_registrar, only: [:new, :show, :edit, :destroy, :update]
|
||||
|
||||
def new
|
||||
@white_ip = WhiteIp.new(registrar: @registrar)
|
||||
end
|
||||
|
||||
def show; end
|
||||
|
||||
def edit; end
|
||||
|
||||
def destroy
|
||||
if @white_ip.destroy
|
||||
flash[:notice] = I18n.t('record_deleted')
|
||||
redirect_to admin_registrar_path(@registrar)
|
||||
else
|
||||
flash.now[:alert] = I18n.t('failed_to_delete_record')
|
||||
render 'show'
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@white_ip = WhiteIp.new(white_ip_params)
|
||||
@registrar = @white_ip.registrar
|
||||
|
||||
if @white_ip.save
|
||||
flash[:notice] = I18n.t('record_created')
|
||||
redirect_to [:admin, @registrar, @white_ip]
|
||||
else
|
||||
flash.now[:alert] = I18n.t('failed_to_create_record')
|
||||
render 'new'
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
if @white_ip.update(white_ip_params)
|
||||
flash[:notice] = I18n.t('record_updated')
|
||||
redirect_to [:admin, @registrar, @white_ip]
|
||||
else
|
||||
flash.now[:alert] = I18n.t('failed_to_update_record')
|
||||
render 'edit'
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_registrar
|
||||
@registrar = Registrar.find_by(id: params[:registrar_id])
|
||||
end
|
||||
|
||||
def white_ip_params
|
||||
params.require(:white_ip).permit(:ipv4, :ipv6, :interface, :registrar_id)
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue