diff --git a/app/models/epp/contact.rb b/app/models/epp/contact.rb index f03d6005f..45a99e5e5 100644 --- a/app/models/epp/contact.rb +++ b/app/models/epp/contact.rb @@ -1,13 +1,10 @@ class Epp::Contact < Contact include EppErrors - attr_accessor :legal_doc - # disable STI, there is type column present self.inheritance_column = :sti_disabled before_validation :manage_permissions - before_validation :check_legal_doc_size def manage_permissions return unless update_prohibited? || delete_prohibited? @@ -15,12 +12,6 @@ class Epp::Contact < Contact false end - def check_legal_doc_size - if @legal_doc - return false if @legal_doc.size < 100.kilobytes - end - end - class << self # support legacy search def find_by_epp_code(code) @@ -49,7 +40,6 @@ class Epp::Contact < Contact legal_frame = f.css('legalDocument').first if legal_frame.present? at[:legal_documents_attributes] = legal_document_attrs(legal_frame) - @legal_doc = legal_document_attrs(legal_frame) end at.merge!(ident_attrs(f.css('ident').first)) if new_record at @@ -164,7 +154,6 @@ class Epp::Contact < Contact legal_frame = frame.css('legalDocument').first at[:legal_documents_attributes] = self.class.legal_document_attrs(legal_frame) - @legal_doc = at[:legal_documents_attributes] self.deliver_emails = true # turn on email delivery for epp diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 26248f7d1..06444c047 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -3,10 +3,9 @@ class Epp::Domain < Domain include EppErrors # TODO: remove this spagetti once data in production is correct. - attr_accessor :is_renewal, :is_transfer, :legal_doc + attr_accessor :is_renewal, :is_transfer before_validation :manage_permissions - before_validation :check_legal_doc_size def manage_permissions return if is_admin # this bad hack for 109086524, refactor later @@ -16,12 +15,6 @@ class Epp::Domain < Domain false end - def check_legal_doc_size - if @legal_doc - return false if @legal_doc.size < 100.kilobytes - end - end - after_validation :validate_contacts def validate_contacts return true if is_renewal || is_transfer @@ -203,7 +196,6 @@ class Epp::Domain < Domain at[:dnskeys_attributes] = dnskeys_attrs(dnskey_frame, action) at[:legal_documents_attributes] = legal_document_from(frame) - @legal_doc = at[:legal_documents_attributes] at end # rubocop: enable Metrics/PerceivedComplexity @@ -485,7 +477,6 @@ class Epp::Domain < Domain if doc = attach_legal_document(Epp::Domain.parse_legal_document_from_frame(frame)) frame.css("legalDocument").first.content = doc.path if doc && doc.persisted? - @legal_doc = doc end at_add = attrs_from(frame.css('add'), current_user, 'add') diff --git a/app/models/legal_document.rb b/app/models/legal_document.rb index 5aef34675..acc6a9e43 100644 --- a/app/models/legal_document.rb +++ b/app/models/legal_document.rb @@ -9,6 +9,8 @@ class LegalDocument < ActiveRecord::Base belongs_to :documentable, polymorphic: true + validates :body, length: { minimum: 1.37 * 1.4 } + before_create :add_creator before_save :save_to_filesystem