mirror of
https://github.com/internetee/registry.git
synced 2025-08-03 08:22:05 +02:00
Merge branch 'master' into registry-475
# Conflicts: # config/locales/et.yml # db/structure.sql
This commit is contained in:
commit
cb4f2b5eeb
79 changed files with 825 additions and 815 deletions
|
@ -1,72 +0,0 @@
|
|||
class Address < ActiveRecord::Base
|
||||
include Versions # version/address_version.rb
|
||||
|
||||
LOCAL_TYPE_SHORT = 'loc'
|
||||
INTERNATIONAL_TYPE_SHORT = 'int'
|
||||
LOCAL_TYPE = 'LocalAddress'
|
||||
TYPES = [
|
||||
LOCAL_TYPE_SHORT,
|
||||
INTERNATIONAL_TYPE_SHORT
|
||||
]
|
||||
|
||||
belongs_to :contact
|
||||
|
||||
def country
|
||||
Country.new(country_code)
|
||||
end
|
||||
|
||||
class << self
|
||||
# def validate_postal_info_types(parsed_frame)
|
||||
# errors, used = [], []
|
||||
# parsed_frame.css('postalInfo').each do |pi|
|
||||
# attr = pi.attributes['type'].try(:value)
|
||||
# errors << {
|
||||
# code: 2003, msg: I18n.t('errors.messages.attr_missing', key: 'type')
|
||||
# } and next unless attr
|
||||
# unless TYPES.include?(attr)
|
||||
# errors << {
|
||||
# code: 2005,
|
||||
# msg: I18n.t('errors.messages.invalid_type'), value: { obj: 'type', val: attr }
|
||||
# }
|
||||
# next
|
||||
# end
|
||||
# errors << {
|
||||
# code: 2005,
|
||||
# msg: I18n.t('errors.messages.repeating_postal_info')
|
||||
# } and next if used.include?(attr)
|
||||
# used << attr
|
||||
# end; errors
|
||||
# end
|
||||
|
||||
def extract_attributes(ah)
|
||||
address_hash = {}
|
||||
ah = ah.first if ah.is_a?(Array)
|
||||
address_hash[:address_attributes] = addr_hash_from_params(ah)
|
||||
address_hash
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# def local?(postal_info)
|
||||
# return :local_address_attributes if postal_info[:type] == LOCAL_TYPE_SHORT
|
||||
# :international_address_attributes
|
||||
# end
|
||||
|
||||
def addr_hash_from_params(addr)
|
||||
return {} if addr.nil?
|
||||
return {} unless addr[:addr].is_a?(Hash)
|
||||
{ country_code: Country.new(addr[:addr][:cc]).try(:alpha2),
|
||||
city: addr[:addr][:city],
|
||||
street: pretty_street(addr[:addr][:street]), # [0],
|
||||
# street2: addr[:addr][:street][1],
|
||||
# street3: addr[:addr][:street][2],
|
||||
zip: addr[:addr][:pc]
|
||||
}.delete_if { |_k, v| v.nil? }
|
||||
end
|
||||
|
||||
def pretty_street(param_street)
|
||||
return param_street.join(',') if param_street.is_a?(Array)
|
||||
param_street
|
||||
end
|
||||
end
|
||||
end
|
|
@ -3,11 +3,11 @@ class Contact < ActiveRecord::Base
|
|||
include EppErrors
|
||||
include UserEvents
|
||||
|
||||
belongs_to :registrar
|
||||
belongs_to :registrar, required: true
|
||||
has_many :domain_contacts
|
||||
has_many :domains, through: :domain_contacts
|
||||
has_many :legal_documents, as: :documentable
|
||||
has_many :registrant_domains, class_name: 'Domain', foreign_key: 'registrant_id' # when contant is registrant
|
||||
has_many :registrant_domains, class_name: 'Domain', foreign_key: 'registrant_id'
|
||||
|
||||
# TODO: remove later
|
||||
has_many :depricated_statuses, class_name: 'DepricatedContactStatus', dependent: :destroy
|
||||
|
@ -19,7 +19,7 @@ class Contact < ActiveRecord::Base
|
|||
|
||||
accepts_nested_attributes_for :legal_documents
|
||||
|
||||
validates :name, :phone, :email, :ident, :ident_type, :registrar, presence: true
|
||||
validates :name, :phone, :email, :ident, :ident_type, presence: true
|
||||
validates :street, :city, :zip, :country_code, presence: true, if: 'self.class.address_processing?'
|
||||
|
||||
validates :phone, format: /\+[0-9]{1,3}\.[0-9]{1,14}?/, phone: true
|
||||
|
@ -429,6 +429,8 @@ class Contact < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def related_domain_descriptions
|
||||
ActiveSupport::Deprecation.warn('Use #domain_names_with_roles')
|
||||
|
||||
@desc = {}
|
||||
|
||||
registrant_domains.each do |dom|
|
||||
|
@ -594,4 +596,28 @@ class Contact < ActiveRecord::Base
|
|||
return unless priv?
|
||||
ident
|
||||
end
|
||||
|
||||
def ident_country
|
||||
Country.new(ident_country_code)
|
||||
end
|
||||
|
||||
def used?
|
||||
registrant_domains.any? || domain_contacts.any?
|
||||
end
|
||||
|
||||
def domain_names_with_roles
|
||||
domain_names = {}
|
||||
|
||||
registrant_domains.pluck(:name).each do |domain_name|
|
||||
domain_names[domain_name] ||= Set.new
|
||||
domain_names[domain_name] << Registrant.name.underscore.to_sym
|
||||
end
|
||||
|
||||
domain_contacts.each do |domain_contact|
|
||||
domain_names[domain_contact.domain.name] ||= Set.new
|
||||
domain_names[domain_contact.domain.name] << domain_contact.type.underscore.to_sym
|
||||
end
|
||||
|
||||
domain_names
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,8 +19,8 @@ class Domain < ActiveRecord::Base
|
|||
# TODO: whois requests ip whitelist for full info for own domains and partial info for other domains
|
||||
# TODO: most inputs should be trimmed before validatation, probably some global logic?
|
||||
|
||||
belongs_to :registrar
|
||||
belongs_to :registrant
|
||||
belongs_to :registrar, required: true
|
||||
belongs_to :registrant, required: true
|
||||
# TODO: should we user validates_associated :registrant here?
|
||||
|
||||
has_many :admin_domain_contacts
|
||||
|
@ -104,8 +104,7 @@ class Domain < ActiveRecord::Base
|
|||
|
||||
validates :name_dirty, domain_name: true, uniqueness: true
|
||||
validates :puny_label, length: { maximum: 63 }
|
||||
validates :period, numericality: { only_integer: true }
|
||||
validates :registrant, :registrar, presence: true
|
||||
validates :period, presence: true, numericality: { only_integer: true }
|
||||
|
||||
validate :validate_reservation
|
||||
def validate_reservation
|
||||
|
|
|
@ -521,9 +521,7 @@ class Epp::Domain < Domain
|
|||
preclean_pendings
|
||||
user = ApiUser.find(pending_json['current_user_id'])
|
||||
frame = Nokogiri::XML(pending_json['frame'])
|
||||
old_registrant_id = registrant_id
|
||||
|
||||
self.deliver_emails = true # turn on email delivery
|
||||
self.statuses.delete(DomainStatus::PENDING_UPDATE)
|
||||
self.upid = user.registrar.id if user.registrar
|
||||
self.up_date = Time.zone.now
|
||||
|
@ -531,11 +529,9 @@ class Epp::Domain < Domain
|
|||
return unless update(frame, user, false)
|
||||
clean_pendings!
|
||||
|
||||
save! # for notification if everything fails
|
||||
save!
|
||||
|
||||
WhoisRecord.find_by(domain_id: id).save # need to reload model
|
||||
DomainMailer.registrant_updated_notification_for_old_registrant(id, old_registrant_id, registrant_id, true).deliver
|
||||
DomainMailer.registrant_updated_notification_for_new_registrant(id, old_registrant_id, registrant_id, true).deliver
|
||||
|
||||
true
|
||||
end
|
||||
|
|
|
@ -61,18 +61,8 @@ module Soap
|
|||
|
||||
def initialize
|
||||
if self.class.username.nil?
|
||||
if Rails.application.secrets.key?(:arireg)
|
||||
arireg = Rails.application.secrets[:arireg].with_indifferent_access
|
||||
self.class.username = arireg[:username]
|
||||
self.class.password = arireg[:password]
|
||||
if self.class.wsdl.nil? # no override of config/environments/* ?
|
||||
self.class.wsdl = arireg[:wsdl]
|
||||
self.class.host = arireg[:host]
|
||||
end
|
||||
else
|
||||
self.class.username = ENV['arireg_username']
|
||||
self.class.password = ENV['arireg_password']
|
||||
end
|
||||
self.class.username = ENV['arireg_username']
|
||||
self.class.password = ENV['arireg_password']
|
||||
end
|
||||
if self.class.wsdl.nil?
|
||||
self.class.wsdl = ENV['arireg_wsdl']
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
class AddressVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_addresses
|
||||
self.sequence_name = :log_addresses_id_seq
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue