Merge pull request #48 from internetee/story/109623634-transfer-domain

Story/109623634 transfer domain
This commit is contained in:
Timo Võhmar 2015-12-23 12:22:58 +02:00
commit 59a588332a
2 changed files with 12 additions and 2 deletions

View file

@ -58,6 +58,11 @@ class Contact < ActiveRecord::Base
before_save :manage_statuses
def manage_statuses
if domain_transfer # very ugly but need better workflow
self.statuses = statuses | [OK, LINKED]
return
end
manage_linked
manage_ok
end
@ -81,6 +86,7 @@ class Contact < ActiveRecord::Base
]
attr_accessor :deliver_emails
attr_accessor :domain_transfer # hack but solves problem faster
#
# STATUSES

View file

@ -3,10 +3,11 @@ class Epp::Domain < Domain
include EppErrors
# TODO: remove this spagetti once data in production is correct.
attr_accessor :is_renewal
attr_accessor :is_renewal, :is_transfer
before_validation :manage_permissions
def manage_permissions
return true if is_transfer
return unless update_prohibited? || delete_prohibited?
add_epp_error('2304', nil, nil, I18n.t(:object_status_prohibits_operation))
false
@ -14,7 +15,7 @@ class Epp::Domain < Domain
after_validation :validate_contacts
def validate_contacts
return true if is_renewal
return true if is_renewal || is_transfer
ok = true
active_admins = admin_domain_contacts.select { |x| !x.marked_for_destruction? }
@ -597,6 +598,8 @@ class Epp::Domain < Domain
# rubocop: disable Metrics/CyclomaticComplexity
def transfer(frame, action, current_user)
@is_transfer = true
case action
when 'query'
return domain_transfers.last if domain_transfers.any?
@ -624,6 +627,7 @@ class Epp::Domain < Domain
oc.registrar_id = registrar_id
oc.copy_from_id = c.id
oc.prefix_code
oc.domain_transfer = true
oc.save!(validate: false)
oc
end