From a7f698a0f425facf82fe3df7d2b63d42d513027a Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Tue, 12 Aug 2014 14:22:06 +0300 Subject: [PATCH] Restructure --- app/models/domain.rb | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/app/models/domain.rb b/app/models/domain.rb index 1962dbcf7..e3040d5eb 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -48,6 +48,8 @@ class Domain < ActiveRecord::Base write_attribute(:name_dirty, value) end + ### CREATE ### + def attach_objects(ph, frame) attach_owner_contact(ph[:registrant]) attach_contacts(self.class.parse_contacts_from_frame(frame)) @@ -120,17 +122,7 @@ class Domain < ActiveRecord::Base self.nameservers.build(attrs) end - ### VALIDATIONS ### - - def validate_nameservers_count - unless nameservers.length.between?(1, 13) - errors.add(:nameservers, :out_of_range, {min: 1, max: 13}) - end - end - - def validate_admin_contacts_count - errors.add(:admin_contacts, :blank) if admin_contacts.empty? - end + ### RENEW ### def renew(cur_exp_date, period, unit='y') # TODO Check how much time before domain exp date can it be renewed @@ -147,6 +139,18 @@ class Domain < ActiveRecord::Base save end + ### VALIDATIONS ### + + def validate_nameservers_count + unless nameservers.length.between?(1, 13) + errors.add(:nameservers, :out_of_range, {min: 1, max: 13}) + end + end + + def validate_admin_contacts_count + errors.add(:admin_contacts, :blank) if admin_contacts.empty? + end + def validate_period return unless period.present? if period_unit == 'd'