FEATURE 104525314.6&7: do not allow changes to admin or tech contact if prohibited

This commit is contained in:
Matt Farnsworth 2015-10-23 19:36:01 +03:00
parent 8f2595c0ca
commit 3fba8442af
2 changed files with 34 additions and 5 deletions

View file

@ -12,9 +12,10 @@ class Domain < ActiveRecord::Base
has_many :domain_contacts, dependent: :destroy
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?
has_many :contacts, through: :domain_contacts, source: :contact
has_many :admin_contacts, through: :admin_domain_contacts, source: :contact
@ -172,6 +173,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'