mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 01:47:18 +02:00
Refactor
This commit is contained in:
parent
096488d175
commit
6990da7675
3 changed files with 15 additions and 11 deletions
|
@ -1,18 +1,11 @@
|
||||||
module Epp::DomainsHelper
|
module Epp::DomainsHelper
|
||||||
def create_domain
|
def create_domain
|
||||||
domain = Domain.new(domain_create_params)
|
@domain = Domain.new(domain_create_params)
|
||||||
|
|
||||||
if domain.save
|
if @domain.save
|
||||||
render '/epp/domains/create'
|
render '/epp/domains/create'
|
||||||
else
|
else
|
||||||
if domain.errors.added?(:name, :taken)
|
handle_domain_name_errors
|
||||||
@code = '2302'
|
|
||||||
@msg = 'Domain name already exists'
|
|
||||||
elsif domain.errors.added?(:name, :epp_domain_reserved)
|
|
||||||
@code = '2302'
|
|
||||||
@msg = domain.errors[:name].first
|
|
||||||
end
|
|
||||||
|
|
||||||
render '/epp/error'
|
render '/epp/error'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -37,4 +30,14 @@ module Epp::DomainsHelper
|
||||||
auth_info: ph[:authInfo][:pw]
|
auth_info: ph[:authInfo][:pw]
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def handle_domain_name_errors
|
||||||
|
[:epp_domain_taken, :epp_domain_reserved].each do |x|
|
||||||
|
if @domain.errors.added?(:name, x)
|
||||||
|
@code = '2302'
|
||||||
|
@msg = @domain.errors[:name].first
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,7 @@ class Domain < ActiveRecord::Base
|
||||||
belongs_to :technical_contact, class_name: 'Contact'
|
belongs_to :technical_contact, class_name: 'Contact'
|
||||||
belongs_to :admin_contact, class_name: 'Contact'
|
belongs_to :admin_contact, class_name: 'Contact'
|
||||||
|
|
||||||
validates :name, domain_name: true, uniqueness: true
|
validates :name, domain_name: true, uniqueness: { message: I18n.t('errors.messages.epp_domain_taken') }
|
||||||
validates :name_puny, domain_name: true
|
validates :name_puny, domain_name: true
|
||||||
|
|
||||||
def name=(value)
|
def name=(value)
|
||||||
|
|
|
@ -23,4 +23,5 @@ en:
|
||||||
errors:
|
errors:
|
||||||
messages:
|
messages:
|
||||||
epp_domain_reserved: 'Domain name is reserved or restricted'
|
epp_domain_reserved: 'Domain name is reserved or restricted'
|
||||||
|
epp_domain_taken: 'Domain name already exists'
|
||||||
hello: "Hello world"
|
hello: "Hello world"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue