Merge: new branch 104525314 from more recent master, merge changes

This commit is contained in:
Matt Farnsworth 2015-10-26 19:09:33 +02:00
commit db3e849c8a
9 changed files with 167 additions and 18 deletions

View file

@ -12,9 +12,10 @@ class Domain < ActiveRecord::Base
# TODO: should we user validates_associated :registrant here?
has_many :admin_domain_contacts
accepts_nested_attributes_for :admin_domain_contacts, allow_destroy: true
accepts_nested_attributes_for :admin_domain_contacts, allow_destroy: !:admin_change_prohibited?, reject_if: :admin_change_prohibited?
has_many :tech_domain_contacts
accepts_nested_attributes_for :tech_domain_contacts, allow_destroy: true
accepts_nested_attributes_for :tech_domain_contacts, allow_destroy: !:tech_change_prohibited?, reject_if: :tech_change_prohibited?
# NB! contacts, admin_contacts, tech_contacts are empty for a new record
has_many :domain_contacts, dependent: :destroy
@ -174,6 +175,14 @@ class Domain < ActiveRecord::Base
nameservers.select { |x| !x.hostname.end_with?(name) }
end
def admin_change_prohibited?
statuses.include? DomainStatus::SERVER_ADMIN_CHANGE_PROHIBITED
end
def tech_change_prohibited?
statuses.include? DomainStatus::SERVER_TECH_CHANGE_PROHIBITED
end
class << self
def convert_period_to_time(period, unit)
return (period.to_i / 365).years if unit == 'd'
@ -354,7 +363,7 @@ class Domain < ActiveRecord::Base
end
end
return false if statuses.include?(DomainStatus::DELETE_CANDIDATE)
return false if statuses.include?(DomainStatus::DELETE_CANDIDATE) || statuses.include?(DomainStatus::FORCE_DELETE)
true
end