113524121-check_minimum_size

This commit is contained in:
Stas 2016-02-21 20:43:43 +02:00
parent bd4477f962
commit b6742c0c09
2 changed files with 24 additions and 1 deletions

View file

@ -1,16 +1,26 @@
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?
add_epp_error('2304', nil, nil, I18n.t(:object_status_prohibits_operation))
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)
@ -39,6 +49,7 @@ 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
@ -153,6 +164,7 @@ 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