mirror of
https://github.com/internetee/registry.git
synced 2025-08-04 00:42:04 +02:00
Merge remote-tracking branch 'origin/master' into 105842700-registrants_portal
# Conflicts: # config/locales/en.yml
This commit is contained in:
commit
6f0360bae6
104 changed files with 2232 additions and 864 deletions
|
@ -1,6 +1,7 @@
|
|||
class Contact < ActiveRecord::Base
|
||||
include Versions # version/contact_version.rb
|
||||
include EppErrors
|
||||
include UserEvents
|
||||
|
||||
belongs_to :registrar
|
||||
has_many :domain_contacts
|
||||
|
@ -28,7 +29,7 @@ class Contact < ActiveRecord::Base
|
|||
uniqueness: { message: :epp_id_taken },
|
||||
format: { with: /\A[\w\-\:\.\_]*\z/i, message: :invalid },
|
||||
length: { maximum: 100, message: :too_long_contact_code }
|
||||
validate :ident_valid_format?
|
||||
validate :val_ident_valid_format?
|
||||
validate :uniq_statuses?
|
||||
validate :validate_html
|
||||
|
||||
|
@ -57,6 +58,11 @@ class Contact < ActiveRecord::Base
|
|||
|
||||
before_save :manage_statuses
|
||||
def manage_statuses
|
||||
if domain_transfer # very ugly but need better workflow
|
||||
self.statuses = statuses | [OK, LINKED]
|
||||
return
|
||||
end
|
||||
|
||||
manage_linked
|
||||
manage_ok
|
||||
end
|
||||
|
@ -80,6 +86,7 @@ class Contact < ActiveRecord::Base
|
|||
]
|
||||
|
||||
attr_accessor :deliver_emails
|
||||
attr_accessor :domain_transfer # hack but solves problem faster
|
||||
|
||||
#
|
||||
# STATUSES
|
||||
|
@ -203,6 +210,21 @@ class Contact < ActiveRecord::Base
|
|||
['DeleteProhibited', SERVER_DELETE_PROHIBITED]
|
||||
]
|
||||
end
|
||||
|
||||
def to_csv
|
||||
CSV.generate do |csv|
|
||||
csv << column_names
|
||||
all.each do |contact|
|
||||
csv << contact.attributes.values_at(*column_names)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def pdf(html)
|
||||
kit = PDFKit.new(html)
|
||||
kit.to_pdf
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def roid
|
||||
|
@ -213,13 +235,18 @@ class Contact < ActiveRecord::Base
|
|||
name || '[no name]'
|
||||
end
|
||||
|
||||
def ident_valid_format?
|
||||
case ident_type
|
||||
when 'priv'
|
||||
case ident_country_code
|
||||
when 'EE'
|
||||
code = Isikukood.new(ident)
|
||||
errors.add(:ident, :invalid_EE_identity_format) unless code.valid?
|
||||
def val_ident_valid_format?
|
||||
case ident_country_code
|
||||
when 'EE'.freeze
|
||||
err_msg = "invalid_EE_identity_format#{"_update" if id}".to_sym
|
||||
case ident_type
|
||||
when 'priv'.freeze
|
||||
errors.add(:ident, err_msg) unless Isikukood.new(ident).valid?
|
||||
when 'org'.freeze
|
||||
# !%w(1 7 8 9).freeze.include?(ident.first) ||
|
||||
if ident.size != 8 || !(ident =~/\A[0-9]{8}\z/)
|
||||
errors.add(:ident, err_msg)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -496,7 +523,8 @@ class Contact < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def update_related_whois_records
|
||||
related_domain_descriptions.each{ |x, y| WhoisRecord.find_by(name: x).save}
|
||||
ids = related_domain_descriptions.keys
|
||||
RegenerateWhoisRecordJob.enqueue(ids, :name) if ids.present?
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue