feat: make technical contacts optional for all domains

- Remove automatic tech contact assignment from admin contacts
- Set minimum tech contacts to 0 for all registrant types
- Update tests to reflect optional tech contacts
- Keep max tech contacts limit from settings

This change implements the requirement to make technical contacts optional
for all domain types while maintaining the maximum limit from settings.
Previously tech contacts were required for organizations and automatically
copied from admin contacts.
This commit is contained in:
oleghasjanov 2025-01-31 15:49:35 +02:00
parent c2affb393f
commit cd5de3bd14
5 changed files with 42 additions and 9 deletions

View file

@ -173,7 +173,7 @@ class Domain < ApplicationRecord
def self.tech_contacts_validation_rules(for_org:)
{
min: -> { for_org ? Setting.tech_contacts_min_count : 0 },
min: -> { 0 },
max: -> { Setting.tech_contacts_max_count }
}
end

View file

@ -381,6 +381,20 @@ class Epp::Domain < Domain
result
end
def admin_contacts_validation_rules(for_org:)
{
min: -> { for_org ? Setting.admin_contacts_min_count : 0 },
max: -> { Setting.admin_contacts_max_count }
}
end
def tech_contacts_validation_rules(for_org:)
{
min: 0,
max: -> { Setting.tech_contacts_max_count }
}
end
end
private
@ -391,4 +405,29 @@ class Epp::Domain < Domain
registrant.code != code
end
def admin_contacts_validation_rules(for_org:)
{
min: -> { for_org ? Setting.admin_contacts_min_count : 0 },
max: -> { Setting.admin_contacts_max_count }
}
end
def require_admin_contacts?
return true if registrant.org?
return false unless registrant.priv?
underage_registrant?
end
def tech_contacts_validation_rules(for_org:)
{
min: 0, # Технический контакт опционален для всех
max: -> { Setting.tech_contacts_max_count }
}
end
def require_tech_contacts?
registrant.present? && registrant.org?
end
end