This commit is contained in:
Martin Lensment 2014-09-22 15:37:48 +03:00
parent cb1a9557de
commit 93930a1243
11 changed files with 1 additions and 292 deletions

View file

@ -1,56 +0,0 @@
class Admin::DomainContactsController < ApplicationController
before_action :set_domain
before_action :set_domain_contact, only: [:destroy]
def new
@domain_contact = @domain.domain_contacts.build(contact_type: params[:type])
end
def create
@domain_contact = @domain.domain_contacts.build(domain_contact_params)
unless @domain_contact.contact
flash.now[:alert] = I18n.t('shared.contact_was_not_found')
render 'new' and return
end
@domain.adding_admin_contact = true if @domain_contact.admin?
@domain.adding_admin_contact = true if @domain_contact.tech?
if @domain.save
flash[:notice] = I18n.t('shared.contact_added')
redirect_to [:admin, @domain]
else
flash.now[:alert] = I18n.t('shared.failed_to_add_contact')
render 'new'
end
end
def destroy
@domain.domain_contacts.select { |x| x == @domain_contact }[0].mark_for_destruction
@domain.deleting_admin_contact = true if @domain_contact.admin?
@domain.deleting_tech_contact = true if @domain_contact.tech?
if @domain.save
flash[:notice] = I18n.t('shared.contact_detached')
else
flash[:alert] = @domain.errors.first[1]
end
redirect_to [:admin, @domain]
end
private
def set_domain
@domain = Domain.find(params[:domain_id])
end
def set_domain_contact
@domain_contact = DomainContact.find(params[:id])
end
def domain_contact_params
params.require(:domain_contact).permit(:contact_id, :contact_type)
end
end

View file

@ -1,56 +0,0 @@
class Admin::DomainStatusesController < ApplicationController
before_action :set_domain
before_action :set_domain_status, only: [:edit, :update, :destroy]
def new
@domain_status = @domain.domain_statuses.build(value: DomainStatus::OK)
end
def create
@domain_status = @domain.domain_statuses.build(domain_status_params)
if @domain.save
flash[:notice] = I18n.t('shared.status_added')
redirect_to [:admin, @domain]
else
flash.now[:alert] = I18n.t('shared.failed_to_add_status')
render 'new'
end
end
def edit; end
def update
if @domain_status.update(domain_status_params)
flash[:notice] = I18n.t('shared.status_updated')
redirect_to [:admin, @domain]
else
flash.now[:alert] = I18n.t('shared.failed_to_update_status')
render 'edit'
end
end
def destroy
if @domain_status.destroy
flash[:notice] = I18n.t('shared.status_deleted')
else
flash[:alert] = I18n.t('shared.failed_to_delete_status')
end
redirect_to [:admin, @domain]
end
private
def set_domain
@domain = Domain.find(params[:domain_id])
end
def set_domain_status
@domain_status = DomainStatus.find(params[:id])
end
def domain_status_params
params.require(:domain_status).permit(:value, :description)
end
end

View file

@ -1,60 +0,0 @@
class Admin::NameserversController < ApplicationController
before_action :set_domain
before_action :set_nameserver, only: [:edit, :update, :destroy]
def new
@nameserver = @domain.nameservers.build
end
def create
@domain.adding_nameserver = true
@nameserver = @domain.nameservers.build(nameserver_params)
if @domain.save
flash[:notice] = I18n.t('shared.nameserver_added')
redirect_to [:admin, @domain]
else
flash.now[:alert] = I18n.t('shared.failed_to_add_nameserver')
render 'new'
end
end
def edit
@nameserver = Nameserver.find(params[:id])
end
def update
if @nameserver.update(nameserver_params)
redirect_to [:admin, @domain]
else
render 'edit'
end
end
def destroy
@domain.deleting_nameserver = true
@domain.nameservers.select { |x| x == @nameserver }[0].mark_for_destruction
if @domain.save
flash[:notice] = I18n.t('shared.nameserver_deleted')
else
flash[:alert] = @domain.errors[:nameservers].first
end
redirect_to [:admin, @domain]
end
private
def set_domain
@domain = Domain.find(params[:domain_id])
end
def set_nameserver
@nameserver = Nameserver.find(params[:id])
end
def nameserver_params
params.require(:nameserver).permit(:hostname, :ipv4, :ipv6)
end
end