mirror of
https://github.com/internetee/registry.git
synced 2025-05-18 10:19:45 +02:00
Refactor
This commit is contained in:
parent
168e6d2a01
commit
660eef414e
8 changed files with 55 additions and 18 deletions
|
@ -3,13 +3,20 @@ class Admin::DomainContactsController < ApplicationController
|
|||
before_action :set_domain_contact, only: [:destroy]
|
||||
|
||||
def new
|
||||
@domain_contact = @domain.domain_contacts.build
|
||||
@domain_contact = @domain.domain_contacts.build(contact_type: params[:type])
|
||||
end
|
||||
|
||||
def create
|
||||
@domain.adding_admin_contact = true
|
||||
@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]
|
||||
|
@ -20,13 +27,14 @@ class Admin::DomainContactsController < ApplicationController
|
|||
end
|
||||
|
||||
def destroy
|
||||
@domain.deleting_admin_contact = true
|
||||
@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_deleted')
|
||||
else
|
||||
flash[:alert] = I18n.t('shared.fail')
|
||||
flash[:alert] = @domain.errors.first[1]
|
||||
end
|
||||
|
||||
redirect_to [:admin, @domain]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue