mirror of
https://github.com/internetee/registry.git
synced 2025-07-26 12:38:25 +02:00
Merge branch 'master' of github.com:domify/registry
Conflicts: app/models/contact.rb
This commit is contained in:
commit
4081cebe73
8 changed files with 25 additions and 18 deletions
|
@ -43,7 +43,8 @@ class EppController < ApplicationController
|
||||||
if Rails.env.test? || Rails.env.development?
|
if Rails.env.test? || Rails.env.development?
|
||||||
# rubocop:disable Rails/Output
|
# rubocop:disable Rails/Output
|
||||||
puts e.backtrace.reverse.join("\n")
|
puts e.backtrace.reverse.join("\n")
|
||||||
puts "\nFROM-EPP-RESCUE: #{e.message}\n"
|
puts "\n BACKTRACE REVERSED!\n"
|
||||||
|
puts "\n FROM-EPP-RESCUE: #{e.message}\n\n\n"
|
||||||
# rubocop:enable Rails/Output
|
# rubocop:enable Rails/Output
|
||||||
else
|
else
|
||||||
logger.error "FROM-EPP-RESCUE: #{e.message}"
|
logger.error "FROM-EPP-RESCUE: #{e.message}"
|
||||||
|
|
|
@ -9,7 +9,7 @@ class Contact < ActiveRecord::Base
|
||||||
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' # when contant is registrant
|
||||||
|
|
||||||
# TODO: remove later
|
# TODO: remove later
|
||||||
has_many :depricated_statuses, class_name: 'DepricatedContactStatus', dependent: :destroy
|
has_many :depricated_statuses, class_name: 'DepricatedContactStatus', dependent: :destroy
|
||||||
|
|
||||||
accepts_nested_attributes_for :legal_documents
|
accepts_nested_attributes_for :legal_documents
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ class Contact < ActiveRecord::Base
|
||||||
validate :ident_valid_format?
|
validate :ident_valid_format?
|
||||||
validate :uniq_statuses?
|
validate :uniq_statuses?
|
||||||
|
|
||||||
after_initialize do
|
after_initialize do
|
||||||
self.statuses = [] if statuses.nil?
|
self.statuses = [] if statuses.nil?
|
||||||
self.status_notes = {} if status_notes.nil?
|
self.status_notes = {} if status_notes.nil?
|
||||||
end
|
end
|
||||||
|
@ -51,6 +51,9 @@ class Contact < ActiveRecord::Base
|
||||||
manage_ok
|
manage_ok
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# for overwrite when doing children loop
|
||||||
|
attr_writer :domains_present
|
||||||
|
|
||||||
scope :current_registrars, ->(id) { where(registrar_id: id) }
|
scope :current_registrars, ->(id) { where(registrar_id: id) }
|
||||||
|
|
||||||
BIC = 'bic'
|
BIC = 'bic'
|
||||||
|
@ -113,12 +116,12 @@ class Contact < ActiveRecord::Base
|
||||||
# "pendingUpdate" status MUST NOT be combined with either
|
# "pendingUpdate" status MUST NOT be combined with either
|
||||||
# "clientUpdateProhibited" or "serverUpdateProhibited" status.
|
# "clientUpdateProhibited" or "serverUpdateProhibited" status.
|
||||||
PENDING_UPDATE = 'pendingUpdate'
|
PENDING_UPDATE = 'pendingUpdate'
|
||||||
# "pendingDelete" MUST NOT be combined with either
|
# "pendingDelete" MUST NOT be combined with either
|
||||||
# "clientDeleteProhibited" or "serverDeleteProhibited" status.
|
# "clientDeleteProhibited" or "serverDeleteProhibited" status.
|
||||||
PENDING_DELETE = 'pendingDelete'
|
PENDING_DELETE = 'pendingDelete'
|
||||||
|
|
||||||
STATUSES = [
|
STATUSES = [
|
||||||
CLIENT_DELETE_PROHIBITED, SERVER_DELETE_PROHIBITED,
|
CLIENT_DELETE_PROHIBITED, SERVER_DELETE_PROHIBITED,
|
||||||
CLIENT_TRANSFER_PROHIBITED,
|
CLIENT_TRANSFER_PROHIBITED,
|
||||||
SERVER_TRANSFER_PROHIBITED, CLIENT_UPDATE_PROHIBITED, SERVER_UPDATE_PROHIBITED,
|
SERVER_TRANSFER_PROHIBITED, CLIENT_UPDATE_PROHIBITED, SERVER_UPDATE_PROHIBITED,
|
||||||
OK, PENDING_CREATE, PENDING_DELETE, PENDING_TRANSFER,
|
OK, PENDING_CREATE, PENDING_DELETE, PENDING_TRANSFER,
|
||||||
|
@ -132,7 +135,7 @@ class Contact < ActiveRecord::Base
|
||||||
|
|
||||||
SERVER_STATUSES = [
|
SERVER_STATUSES = [
|
||||||
SERVER_UPDATE_PROHIBITED,
|
SERVER_UPDATE_PROHIBITED,
|
||||||
SERVER_DELETE_PROHIBITED,
|
SERVER_DELETE_PROHIBITED,
|
||||||
SERVER_TRANSFER_PROHIBITED
|
SERVER_TRANSFER_PROHIBITED
|
||||||
]
|
]
|
||||||
#
|
#
|
||||||
|
@ -306,18 +309,13 @@ class Contact < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# optimization under children loop,
|
# optimization under children loop,
|
||||||
# otherwise bullet will not be happy
|
# otherwise bullet will not be happy
|
||||||
def domains_present?
|
def domains_present?
|
||||||
return @domains_present if @domains_present
|
return @domains_present if @domains_present
|
||||||
domain_contacts.present? || registrant_domains.present?
|
domain_contacts.present? || registrant_domains.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
# for overwrite when doing children loop
|
|
||||||
def domains_present=(boolean)
|
|
||||||
@domains_present = boolean
|
|
||||||
end
|
|
||||||
|
|
||||||
def manage_linked
|
def manage_linked
|
||||||
if domains_present?
|
if domains_present?
|
||||||
set_linked
|
set_linked
|
||||||
|
|
|
@ -528,7 +528,7 @@ class Epp::Domain < Domain
|
||||||
return if registrant.registrar_id == registrar_id
|
return if registrant.registrar_id == registrar_id
|
||||||
|
|
||||||
is_other_domains_contact = DomainContact.where('contact_id = ? AND domain_id != ?', registrant_id, id).count > 0
|
is_other_domains_contact = DomainContact.where('contact_id = ? AND domain_id != ?', registrant_id, id).count > 0
|
||||||
if registrant.domains_owned.count > 1 || is_other_domains_contact
|
if registrant.registrant_domains.count > 1 || is_other_domains_contact
|
||||||
oc = copy_and_transfer_contact(registrant_id, registrar_id)
|
oc = copy_and_transfer_contact(registrant_id, registrar_id)
|
||||||
self.registrant_id = oc.id
|
self.registrant_id = oc.id
|
||||||
else
|
else
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
%th{class: 'col-xs-4'}= t(:registrar)
|
%th{class: 'col-xs-4'}= t(:registrar)
|
||||||
%th{class: 'col-xs-4'}= t(:valid_to)
|
%th{class: 'col-xs-4'}= t(:valid_to)
|
||||||
%tbody
|
%tbody
|
||||||
- @contact.domains_owned.each do |x|
|
- @contact.registrant_domains.each do |x|
|
||||||
%tr
|
%tr
|
||||||
%td= link_to(x.name, [:admin, x])
|
%td= link_to(x.name, [:admin, x])
|
||||||
%td= link_to(x.registrar, [:admin, x.registrar])
|
%td= link_to(x.registrar, [:admin, x.registrar])
|
||||||
|
|
|
@ -3,7 +3,7 @@ Fabricator(:domain) do
|
||||||
valid_to Date.new(2014, 8, 7)
|
valid_to Date.new(2014, 8, 7)
|
||||||
period 1
|
period 1
|
||||||
period_unit 'y'
|
period_unit 'y'
|
||||||
registrant(fabricator: :registrant)
|
registrant { Fabricate(:registrant) }
|
||||||
nameservers(count: 3)
|
nameservers(count: 3)
|
||||||
admin_domain_contacts(count: 1) { Fabricate(:admin_domain_contact) }
|
admin_domain_contacts(count: 1) { Fabricate(:admin_domain_contact) }
|
||||||
tech_domain_contacts(count: 1) { Fabricate(:tech_domain_contact) }
|
tech_domain_contacts(count: 1) { Fabricate(:tech_domain_contact) }
|
||||||
|
|
|
@ -29,6 +29,7 @@ describe ContactMailer do
|
||||||
before :all do
|
before :all do
|
||||||
@domain = Fabricate(:domain)
|
@domain = Fabricate(:domain)
|
||||||
@contact = @domain.registrant
|
@contact = @domain.registrant
|
||||||
|
@contact.reload # until figured out why registrant_domains not loaded
|
||||||
@contact.deliver_emails = true
|
@contact.deliver_emails = true
|
||||||
@contact.email = 'test@example.org' # new email
|
@contact.email = 'test@example.org' # new email
|
||||||
@mail = ContactMailer.email_updated(@contact)
|
@mail = ContactMailer.email_updated(@contact)
|
||||||
|
|
|
@ -137,8 +137,8 @@ describe Contact do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not have relation' do
|
it 'should not have relation with domains' do
|
||||||
@contact.relations_with_domain?.should == false
|
@contact.domains_present?.should == false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'bic should be valid' do
|
it 'bic should be valid' do
|
||||||
|
@ -234,9 +234,15 @@ describe Contact do
|
||||||
|
|
||||||
it 'should have related domain descriptions hash' do
|
it 'should have related domain descriptions hash' do
|
||||||
contact = @domain.registrant
|
contact = @domain.registrant
|
||||||
|
contact.reload # somehow it registrant_domains are empty?
|
||||||
contact.related_domain_descriptions.should == { "#{@domain.name}" => [:registrant] }
|
contact.related_domain_descriptions.should == { "#{@domain.name}" => [:registrant] }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should have related domain descriptions hash when find directly' do
|
||||||
|
contact = @domain.registrant
|
||||||
|
Contact.find(contact.id).related_domain_descriptions.should == { "#{@domain.name}" => [:registrant] }
|
||||||
|
end
|
||||||
|
|
||||||
it 'should have related domain descriptions hash' do
|
it 'should have related domain descriptions hash' do
|
||||||
contact = @domain.contacts.first
|
contact = @domain.contacts.first
|
||||||
contact.related_domain_descriptions.should == { "#{@domain.name}" => [:admin] }
|
contact.related_domain_descriptions.should == { "#{@domain.name}" => [:admin] }
|
||||||
|
|
|
@ -48,6 +48,7 @@ def create_settings
|
||||||
|
|
||||||
Setting.client_side_status_editing_enabled = true
|
Setting.client_side_status_editing_enabled = true
|
||||||
|
|
||||||
|
# speedup and easier to create fabrications
|
||||||
@fixed_registrar =
|
@fixed_registrar =
|
||||||
Registrar.find_by_name('fixed registrar') ||
|
Registrar.find_by_name('fixed registrar') ||
|
||||||
Fabricate(:registrar, name: 'fixed registrar', code: 'FIXED')
|
Fabricate(:registrar, name: 'fixed registrar', code: 'FIXED')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue