From 1d19bc9863be87a4a05ed0668aba1f08e1de0906 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Thu, 10 Sep 2015 11:45:36 +0300 Subject: [PATCH 01/41] Add transfer prohibit to admin #2922 --- app/models/domain_status.rb | 26 +++++++++++++------------- app/models/epp/domain.rb | 4 +++- spec/epp/domain_spec.rb | 17 +++++++++++++++++ 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/app/models/domain_status.rb b/app/models/domain_status.rb index 66908c16e..3f88de39f 100644 --- a/app/models/domain_status.rb +++ b/app/models/domain_status.rb @@ -122,40 +122,40 @@ class DomainStatus < ActiveRecord::Base class << self def admin_statuses [ - SERVER_HOLD, + SERVER_HOLD, # sync with admin_statuses_map - # SERVER_MANUAL_INZONE, - # SERVER_RENEW_PROHIBITED, + # SERVER_MANUAL_INZONE, + # SERVER_RENEW_PROHIBITED, # SERVER_TRANSFER_PROHIBITED, # SERVER_REGISTRANT_CHANGE_PROHIBITED, - # SERVER_ADMIN_CHANGE_PROHIBITED, + # SERVER_ADMIN_CHANGE_PROHIBITED, # SERVER_TECH_CHANGE_PROHIBITED, - SERVER_DELETE_PROHIBITED, + SERVER_DELETE_PROHIBITED, SERVER_UPDATE_PROHIBITED ] end def admin_statuses_map [ - ['Hold', SERVER_HOLD], + ['Hold', SERVER_HOLD], # sync with admin_statuses - # ['ManualInzone', SERVER_MANUAL_INZONE], + # ['ManualInzone', SERVER_MANUAL_INZONE], # [''], - # ['RenewProhibited', SERVER_RENEW_PROHIBITED], - # ['TransferProhibited', SERVER_TRANSFER_PROHIBITED], + # ['RenewProhibited', SERVER_RENEW_PROHIBITED], + ['TransferProhibited', SERVER_TRANSFER_PROHIBITED], # ['RegistrantChangeProhibited', SERVER_REGISTRANT_CHANGE_PROHIBITED], - # ['AdminChangeProhibited', SERVER_ADMIN_CHANGE_PROHIBITED], + # ['AdminChangeProhibited', SERVER_ADMIN_CHANGE_PROHIBITED], # ['TechChangeProhibited', SERVER_TECH_CHANGE_PROHIBITED], # [''], - ['UpdateProhibited', SERVER_UPDATE_PROHIBITED], + ['UpdateProhibited', SERVER_UPDATE_PROHIBITED], ['DeleteProhibited', SERVER_DELETE_PROHIBITED] ] end def admin_not_deletable_statuses [ - OK, - INACTIVE, + OK, + INACTIVE, FORCE_DELETE, PENDING_CREATE, PENDING_DELETE, diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index c2ac2bcaf..68e564f85 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -757,7 +757,9 @@ class Epp::Domain < Domain DomainStatus::PENDING_DELETE, DomainStatus::PENDING_RENEW, DomainStatus::PENDING_TRANSFER, - DomainStatus::FORCE_DELETE + DomainStatus::FORCE_DELETE, + DomainStatus::SERVER_TRANSFER_PROHIBITED, + DomainStatus::CLIENT_TRANSFER_PROHIBITED ]).empty? end diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index 9a9f5c1bc..1c6b86117 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -1767,6 +1767,23 @@ describe 'EPP Domain', epp: true do end end + it 'should not transfer when in prohibited status' do + domain.statuses = [DomainStatus::SERVER_TRANSFER_PROHIBITED] + domain.save + + pw = domain.auth_info + xml = domain_transfer_xml({ + name: { value: domain.name }, + authInfo: { pw: { value: pw } } + }) + + login_as :registrar2 do + response = epp_plain_request(xml) + response[:msg].should == 'Object status prohibits operation' + response[:result_code].should == '2304' + end + end + ### UPDATE ### it 'should update right away without update pending status' do existing_pw = domain.auth_info From 2438a4ac7560c94f14febb3732b3309d13bf0a96 Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Thu, 10 Sep 2015 14:49:37 +0300 Subject: [PATCH 02/41] Transfer should add copy_from_id --- app/models/epp/domain.rb | 38 +++---------- config/database-example-development.yml | 18 +++++++ db/migrate/20150910113839_add_copy_from_id.rb | 5 ++ db/schema-read-only.rb | 3 +- db/structure.sql | 5 +- spec/epp/domain_spec.rb | 54 ++++++++++++++++--- 6 files changed, 83 insertions(+), 40 deletions(-) create mode 100644 db/migrate/20150910113839_add_copy_from_id.rb diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 27c88cd59..9ac0df753 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -540,29 +540,15 @@ class Epp::Domain < Domain oc = c.deep_clone oc.code = nil oc.registrar_id = registrar_id + oc.copy_from_id = c.id oc.prefix_code oc.save!(validate: false) oc end - def transfer_contact(contact_id, registrar_id) - oc = Contact.find(contact_id) # n+1 workaround - oc.registrar_id = registrar_id - oc.generate_new_code! - oc.save!(validate: false) - oc - end - def transfer_registrant(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 - if registrant.registrant_domains.count > 1 || is_other_domains_contact - oc = copy_and_transfer_contact(registrant_id, registrar_id) - self.registrant_id = oc.id - else - transfer_contact(registrant_id, registrar_id) - end + self.registrant_id = copy_and_transfer_contact(registrant_id, registrar_id).id end def transfer_domain_contacts(registrar_id) @@ -570,22 +556,14 @@ class Epp::Domain < Domain contacts.each do |c| next if copied_ids.include?(c.id) || c.registrar_id == registrar_id - is_other_domains_contact = DomainContact.where('contact_id = ? AND domain_id != ?', c.id, id).count > 0 - # if contact used to be owner contact but was copied, then contact must be transferred - # (registrant_id_was != c.id) - if c.domains.count > 1 || is_other_domains_contact - # copy contact - if registrant_id_was == c.id # owner contact was copied previously, do not copy it again - oc = OpenStruct.new(id: registrant_id) - else - oc = copy_and_transfer_contact(c.id, registrar_id) - end - - domain_contacts.where(contact_id: c.id).update_all({ contact_id: oc.id }) # n+1 workaround - copied_ids << c.id + if registrant_id_was == c.id # registrant was copied previously, do not copy it again + oc = OpenStruct.new(id: registrant_id) else - transfer_contact(c.id, registrar_id) + oc = copy_and_transfer_contact(c.id, registrar_id) end + + domain_contacts.where(contact_id: c.id).update_all({ contact_id: oc.id }) # n+1 workaround + copied_ids << c.id end end diff --git a/config/database-example-development.yml b/config/database-example-development.yml index 6cfce0d79..8bcaf097f 100644 --- a/config/database-example-development.yml +++ b/config/database-example-development.yml @@ -21,3 +21,21 @@ api_log_development: registrant_write_development: <<: *default database: registry_development + + +test: + <<: *default + database: registry_test + +whois_test: + <<: *default + database: registry_whois_test + +api_log_test: + <<: *default + database: registry_api_log_test + +registrant_write_test: + <<: *default + database: registry_test + diff --git a/db/migrate/20150910113839_add_copy_from_id.rb b/db/migrate/20150910113839_add_copy_from_id.rb new file mode 100644 index 000000000..c023750ff --- /dev/null +++ b/db/migrate/20150910113839_add_copy_from_id.rb @@ -0,0 +1,5 @@ +class AddCopyFromId < ActiveRecord::Migration + def change + add_column :contacts, :copy_from_id, :integer + end +end diff --git a/db/schema-read-only.rb b/db/schema-read-only.rb index 79739bb06..7bcf1f877 100644 --- a/db/schema-read-only.rb +++ b/db/schema-read-only.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150825125118) do +ActiveRecord::Schema.define(version: 20150910113839) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -201,6 +201,7 @@ ActiveRecord::Schema.define(version: 20150825125118) do t.integer "legacy_id" t.string "statuses", array: true t.hstore "status_notes" + t.integer "copy_from_id" end add_index "contacts", ["code"], name: "index_contacts_on_code", using: :btree diff --git a/db/structure.sql b/db/structure.sql index 74cddb0e9..b2c6c0bca 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -596,7 +596,8 @@ CREATE TABLE contacts ( state character varying, legacy_id integer, statuses character varying[], - status_notes hstore + status_notes hstore, + copy_from_id integer ); @@ -4928,3 +4929,5 @@ INSERT INTO schema_migrations (version) VALUES ('20150810114746'); INSERT INTO schema_migrations (version) VALUES ('20150825125118'); +INSERT INTO schema_migrations (version) VALUES ('20150910113839'); + diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index 9a9f5c1bc..732588d5a 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -1181,9 +1181,10 @@ describe 'EPP Domain', epp: true do end # all domain contacts should be under registrar2 now + domain.reload domain.registrant.reload domain.registrant.registrar_id.should == @registrar2.id - domain.registrant.id.should == original_oc_id + domain.registrant.id.should_not == original_oc_id # must generate new code domain.registrant.code.should_not == original_oc_code @@ -1289,8 +1290,7 @@ describe 'EPP Domain', epp: true do # all domain contacts should be under registrar2 now domain.reload domain.registrant.registrar_id.should == @registrar2.id - # registrant should not be a new record - domain.registrant.id.should == original_oc_id + domain.registrant.id.should_not == original_oc_id # old contact must not change old_contact.registrar_id.should == @registrar1.id @@ -1305,8 +1305,8 @@ describe 'EPP Domain', epp: true do # there should be 2 references to the new contact domain.domain_contacts.where(contact_id: new_contact.id).count.should == 2 - # there should be only one new contact object - (original_contact_count + 1).should == Contact.count + # there should be four new contact object + (original_contact_count + 4).should == Contact.count # and no new references original_domain_contact_count.should == DomainContact.count @@ -1344,7 +1344,7 @@ describe 'EPP Domain', epp: true do domain.reload domain.registrant.registrar_id.should == @registrar2.id # registrant should not be a new record - domain.registrant.id.should == original_oc_id + domain.registrant.id.should_not == original_oc_id # old contact must not change old_contact.registrar_id.should == @registrar1.id @@ -1367,8 +1367,8 @@ describe 'EPP Domain', epp: true do # there should be 1 reference to the new contact 2 (tech) domain.domain_contacts.where(contact_id: new_contact_2.id).count.should == 1 - # there should be only two new contact objects - (original_contact_count + 2).should == Contact.count + # there should be four new contact objects + (original_contact_count + 5).should == Contact.count # and no new references original_domain_contact_count.should == DomainContact.count @@ -1435,6 +1435,44 @@ describe 'EPP Domain', epp: true do original_contacts_codes.sort.should == domain.contacts.pluck(:code).sort end + fit 'transfers domain contact should populate copy_from_id' do + d = Fabricate(:domain) + d.tech_contacts << domain.registrant + + original_oc_id = domain.registrant.id + original_oc_code = domain.registrant.code + domain.registrant.copy_from_id.should == nil + + original_contact_codes = domain.contacts.pluck(:code) + + pw = domain.auth_info + xml = domain_transfer_xml({ + name: { value: domain.name }, + authInfo: { pw: { value: pw } } + }) + + login_as :registrar2 do + response = epp_plain_request(xml) + response[:msg].should == 'Command completed successfully' + response[:result_code].should == '1000' + end + + # all domain contacts should be under registrar2 now + domain.reload + domain.registrant.registrar_id.should == @registrar2.id + # registrant should be a new record + domain.registrant.id.should_not == original_oc_id + domain.registrant.copy_from_id.should == original_oc_id + # must generate new code + domain.registrant.code.should_not == original_oc_code + + + domain.contacts.each do |c| + c.registrar_id.should == @registrar2.id + original_contact_codes.include?(c.code).should_not == true + end + end + it 'should not creates transfer without password' do xml = domain_transfer_xml({ name: { value: domain.name } From a40e1e6178f2a7114757add20b33c683bfa354d3 Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Thu, 10 Sep 2015 14:54:05 +0300 Subject: [PATCH 03/41] Rubocop updates --- app/models/epp/domain.rb | 1 - spec/epp/domain_spec.rb | 1 - 2 files changed, 2 deletions(-) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 7d6e2eab0..03433e9c2 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -512,7 +512,6 @@ class Epp::Domain < Domain ### TRANSFER ### - # rubocop: disable Metrics/PerceivedComplexity # rubocop: disable Metrics/CyclomaticComplexity def transfer(frame, action, current_user) case action diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index 24cff2356..771d87b63 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -1466,7 +1466,6 @@ describe 'EPP Domain', epp: true do # must generate new code domain.registrant.code.should_not == original_oc_code - domain.contacts.each do |c| c.registrar_id.should == @registrar2.id original_contact_codes.include?(c.code).should_not == true From a82a5711be472c01950a4f1c7aeb8334f5627aa3 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Thu, 10 Sep 2015 15:31:00 +0300 Subject: [PATCH 04/41] Pending delete improvements #2623 --- app/models/domain.rb | 31 ++++++++++++++----- app/models/epp/domain.rb | 14 ++++++++- .../admin/domains/partials/_general.haml | 9 ++++++ spec/epp/domain_spec.rb | 9 +++--- spec/models/domain_spec.rb | 6 +++- 5 files changed, 56 insertions(+), 13 deletions(-) diff --git a/app/models/domain.rb b/app/models/domain.rb index b5fbe0fed..10942ada3 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -330,7 +330,6 @@ class Domain < ActiveRecord::Base end def server_holdable? - return false if outzone_at > Time.zone.now return false if statuses.include?(DomainStatus::SERVER_HOLD) return false if statuses.include?(DomainStatus::SERVER_MANUAL_INZONE) true @@ -613,7 +612,6 @@ class Domain < ActiveRecord::Base statuses << DomainStatus::EXPIRED end - # TODO: This looks odd - outzone_at and delete_at will be the same value? def set_expired # TODO: currently valid_to attribute update logic is open # self.valid_to = valid_from + self.class.convert_period_to_time(period, period_unit) @@ -642,7 +640,7 @@ class Domain < ActiveRecord::Base end def pending_update_prohibited? - (statuses & [ + (statuses_was & [ DomainStatus::CLIENT_UPDATE_PROHIBITED, DomainStatus::SERVER_UPDATE_PROHIBITED, DomainStatus::PENDING_CREATE, @@ -666,17 +664,24 @@ class Domain < ActiveRecord::Base end def pending_delete_prohibited? - (statuses & [ + (statuses_was & [ DomainStatus::CLIENT_DELETE_PROHIBITED, DomainStatus::SERVER_DELETE_PROHIBITED, + DomainStatus::CLIENT_UPDATE_PROHIBITED, + DomainStatus::SERVER_UPDATE_PROHIBITED, DomainStatus::PENDING_CREATE, - DomainStatus::PENDING_UPDATE, - DomainStatus::PENDING_DELETE, DomainStatus::PENDING_RENEW, - DomainStatus::PENDING_TRANSFER + DomainStatus::PENDING_TRANSFER, + DomainStatus::PENDING_UPDATE, + DomainStatus::PENDING_DELETE ]).present? end + # let's use positive method names + def pending_deletable? + !pending_delete_prohibited? + end + def set_pending_delete if pending_delete_prohibited? logger.info "DOMAIN STATUS UPDATE ISSUE ##{id}: PENDING_DELETE not allowed to set. [#{statuses}]" @@ -685,13 +690,25 @@ class Domain < ActiveRecord::Base statuses << DomainStatus::PENDING_DELETE end + def set_server_hold + statuses << DomainStatus::SERVER_HOLD + end + + # rubocop: disable Metrics/CyclomaticComplexity + # rubocop: disable Metrics/PerceivedComplexity def manage_automatic_statuses if statuses.empty? && valid? statuses << DomainStatus::OK elsif statuses.length > 1 || !valid? statuses.delete(DomainStatus::OK) end + + p_d = statuses.include?(DomainStatus::PENDING_DELETE) + s_h = (statuses & [DomainStatus::SERVER_MANUAL_INZONE, DomainStatus::SERVER_HOLD]).empty? + statuses << DomainStatus::SERVER_HOLD if p_d && s_h end + # rubocop: enable Metrics/CyclomaticComplexity + # rubocop: enable Metrics/PerceivedComplexity def children_log log = HashWithIndifferentAccess.new diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index cb73dd358..6ff00c231 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -472,6 +472,8 @@ class Epp::Domain < Domain ) end + # rubocop: disable Metrics/PerceivedComplexity + # rubocop: disable Metrics/CyclomaticComplexity def epp_destroy(frame, user_id, verify = true) return false unless valid? @@ -485,9 +487,19 @@ class Epp::Domain < Domain manage_automatic_statuses true # aka 1001 pending_delete else - set_expired! + throw :epp_error, { + code: '2304', + msg: I18n.t(:object_status_prohibits_operation) + } unless pending_deletable? + + self.delete_at = Time.zone.now + Setting.redemption_grace_period.days + set_pending_delete + set_server_hold if server_holdable? + save(validate: false) end end + # rubocop: enable Metrics/PerceivedComplexity + # rubocop: enable Metrics/CyclomaticComplexity ### RENEW ### diff --git a/app/views/admin/domains/partials/_general.haml b/app/views/admin/domains/partials/_general.haml index 91b4aeabd..d433a1302 100644 --- a/app/views/admin/domains/partials/_general.haml +++ b/app/views/admin/domains/partials/_general.haml @@ -21,3 +21,12 @@ %dt= t(:valid_to) %dd= l(@domain.valid_to) + + %dt= t(:outzone_at) + %dd= l(@domain.outzone_at) + + %dt= t(:delete_at) + %dd= l(@domain.delete_at) + + %dt= t(:force_delete_at) + %dd= l(@domain.force_delete_at) diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index 1c6b86117..d24ba37fe 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -2014,7 +2014,7 @@ describe 'EPP Domain', epp: true do _anonymus: [ { contact: { value: 'FIXED:MAK21', attrs: { type: 'tech' } } }, { status: { value: 'Payment overdue.', attrs: { s: 'clientHold', lang: 'en' } } }, - { status: { value: '', attrs: { s: 'clientUpdateProhibited' } } } + { status: { value: '', attrs: { s: 'clientRenewProhibited' } } } ] ] }, { @@ -2044,6 +2044,7 @@ describe 'EPP Domain', epp: true do Fabricate(:contact, code: 'FIXED:MAK21') response = epp_plain_request(xml) + response[:results][0][:result_code].should == '1000' d = Domain.last @@ -2056,7 +2057,7 @@ describe 'EPP Domain', epp: true do d.statuses.count.should == 2 d.statuses.include?('clientHold').should == true - d.statuses.include?('clientUpdateProhibited').should == true + d.statuses.include?('clientRenewProhibited').should == true d.dnskeys.count.should == 2 @@ -2238,7 +2239,7 @@ describe 'EPP Domain', epp: true do _anonymus: [ { contact: { value: 'FIXED:CITIZEN_1234', attrs: { type: 'tech' } } }, { status: { value: 'Payment overdue.', attrs: { s: 'clientHold', lang: 'en' } } }, - { status: { value: '', attrs: { s: 'clientUpdateProhibited' } } } + { status: { value: '', attrs: { s: 'clientRenewProhibited' } } } ] ] }, { @@ -2305,7 +2306,7 @@ describe 'EPP Domain', epp: true do d.dnskeys.count.should == 1 d.statuses.count.should == 1 - d.statuses.first.should == 'clientUpdateProhibited' + d.statuses.first.should == 'clientRenewProhibited' rem_ns = d.nameservers.find_by(hostname: 'ns1.example.com') rem_ns.should be_falsey diff --git a/spec/models/domain_spec.rb b/spec/models/domain_spec.rb index 48cfa0dc4..dc21a19f0 100644 --- a/spec/models/domain_spec.rb +++ b/spec/models/domain_spec.rb @@ -454,8 +454,12 @@ describe Domain do @domain.set_pending_delete @domain.save - @domain.statuses.should == ['pendingDelete'] + @domain.statuses.should == ['pendingDelete', 'serverHold'] @domain.pending_delete?.should == true + @domain.statuses = ['serverManualInzone'] + @domain.save + @domain.set_pending_delete + @domain.statuses.sort.should == ['pendingDelete', 'serverManualInzone'].sort @domain.statuses = DomainStatus::OK # restore end From 4951dbf1eac5fe155687d084213c7658e555dadb Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Thu, 10 Sep 2015 15:41:46 +0300 Subject: [PATCH 05/41] Fix tests #2623 --- spec/models/domain_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/models/domain_spec.rb b/spec/models/domain_spec.rb index dc21a19f0..8ec5f4b25 100644 --- a/spec/models/domain_spec.rb +++ b/spec/models/domain_spec.rb @@ -467,6 +467,7 @@ describe Domain do @domain.statuses = DomainStatus::OK # restore @domain.pending_delete?.should == false @domain.statuses << DomainStatus::CLIENT_DELETE_PROHIBITED + @domain.save @domain.set_pending_delete.should == nil From 0ef04b2506c84433179248e3a1636306e1612b2e Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Thu, 10 Sep 2015 16:21:40 +0300 Subject: [PATCH 06/41] Refactor #2623 --- app/controllers/epp/domains_controller.rb | 1 - app/models/epp/domain.rb | 22 +++++++++++++--------- db/schema-read-only.rb | 1 + db/structure.sql | 3 +++ 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/app/controllers/epp/domains_controller.rb b/app/controllers/epp/domains_controller.rb index d3111ddfa..1e778b839 100644 --- a/app/controllers/epp/domains_controller.rb +++ b/app/controllers/epp/domains_controller.rb @@ -63,7 +63,6 @@ class Epp::DomainsController < EppController def delete authorize! :delete, @domain, @password - # all includes for bullet @domain = Epp::Domain.where(id: @domain.id).includes(nameservers: :versions).first diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index a19a0d772..c3215d774 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -487,17 +487,21 @@ class Epp::Domain < Domain manage_automatic_statuses true # aka 1001 pending_delete else - throw :epp_error, { - code: '2304', - msg: I18n.t(:object_status_prohibits_operation) - } unless pending_deletable? - - self.delete_at = Time.zone.now + Setting.redemption_grace_period.days - set_pending_delete - set_server_hold if server_holdable? - save(validate: false) + set_pending_delete! end end + + def set_pending_delete! + throw :epp_error, { + code: '2304', + msg: I18n.t(:object_status_prohibits_operation) + } unless pending_deletable? + + self.delete_at = Time.zone.now + Setting.redemption_grace_period.days + set_pending_delete + set_server_hold if server_holdable? + save(validate: false) + end # rubocop: enable Metrics/PerceivedComplexity # rubocop: enable Metrics/CyclomaticComplexity diff --git a/db/schema-read-only.rb b/db/schema-read-only.rb index 7bcf1f877..f7de8c32d 100644 --- a/db/schema-read-only.rb +++ b/db/schema-read-only.rb @@ -201,6 +201,7 @@ ActiveRecord::Schema.define(version: 20150910113839) do t.integer "legacy_id" t.string "statuses", array: true t.hstore "status_notes" + t.integer "legacy_history_id" t.integer "copy_from_id" end diff --git a/db/structure.sql b/db/structure.sql index b2c6c0bca..c517c6576 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -597,6 +597,7 @@ CREATE TABLE contacts ( legacy_id integer, statuses character varying[], status_notes hstore, + legacy_history_id integer, copy_from_id integer ); @@ -4929,5 +4930,7 @@ INSERT INTO schema_migrations (version) VALUES ('20150810114746'); INSERT INTO schema_migrations (version) VALUES ('20150825125118'); +INSERT INTO schema_migrations (version) VALUES ('20150827151906'); + INSERT INTO schema_migrations (version) VALUES ('20150910113839'); From ce3397dbfb61b90cf9d924657458d0c53ba21007 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Thu, 10 Sep 2015 17:29:46 +0300 Subject: [PATCH 07/41] Disable rubocop #2623 --- app/models/epp/domain.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index c3215d774..5d54fb7d2 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -472,8 +472,6 @@ class Epp::Domain < Domain ) end - # rubocop: disable Metrics/PerceivedComplexity - # rubocop: disable Metrics/CyclomaticComplexity def epp_destroy(frame, user_id, verify = true) return false unless valid? @@ -502,8 +500,6 @@ class Epp::Domain < Domain set_server_hold if server_holdable? save(validate: false) end - # rubocop: enable Metrics/PerceivedComplexity - # rubocop: enable Metrics/CyclomaticComplexity ### RENEW ### From 34e43422190eb94b7decec9e958c10eda7b09aaf Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Thu, 10 Sep 2015 18:14:06 +0300 Subject: [PATCH 08/41] Add account activities view to admin #2893 --- .../admin/account_activities_controller.rb | 28 +++++++ app/models/ability.rb | 1 + app/views/admin/account_activities/index.haml | 74 +++++++++++++++++++ app/views/layouts/admin/application.haml | 1 + config/locales/en.yml | 1 + config/routes.rb | 1 + spec/features/admin/account_activity_spec.rb | 45 +++++++++++ 7 files changed, 151 insertions(+) create mode 100644 app/controllers/admin/account_activities_controller.rb create mode 100644 app/views/admin/account_activities/index.haml create mode 100644 spec/features/admin/account_activity_spec.rb diff --git a/app/controllers/admin/account_activities_controller.rb b/app/controllers/admin/account_activities_controller.rb new file mode 100644 index 000000000..77e5535ce --- /dev/null +++ b/app/controllers/admin/account_activities_controller.rb @@ -0,0 +1,28 @@ +class Admin::AccountActivitiesController < AdminController + load_and_authorize_resource + + def index # rubocop: disable Metrics/AbcSize + params[:q] ||= {} + # account = current_user.registrar.cash_account + + ca_cache = params[:q][:created_at_lteq] + begin + end_time = params[:q][:created_at_lteq].try(:to_date) + params[:q][:created_at_lteq] = end_time.try(:end_of_day) + rescue + logger.warn('Invalid date') + end + + @q = AccountActivity.includes(:invoice, account: :registrar).search(params[:q]) + @q.sorts = 'id desc' if @q.sorts.empty? + + respond_to do |format| + format.html { @account_activities = @q.result.page(params[:page]) } + format.csv do + send_data @q.result.to_csv, filename: "account_activities_#{Time.zone.now.to_formatted_s(:number)}.csv" + end + end + + params[:q][:created_at_lteq] = ca_cache + end +end diff --git a/app/models/ability.rb b/app/models/ability.rb index fc874f129..2c85cf8aa 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -99,6 +99,7 @@ class Ability can :manage, MailTemplate can :manage, Invoice can :manage, WhiteIp + can :manage, AccountActivity can :read, ApiLog::EppLog can :read, ApiLog::ReppLog can :update, :pending diff --git a/app/views/admin/account_activities/index.haml b/app/views/admin/account_activities/index.haml new file mode 100644 index 000000000..35e270dce --- /dev/null +++ b/app/views/admin/account_activities/index.haml @@ -0,0 +1,74 @@ +- content_for :actions do + = link_to(t(:export_csv), url_for(params.merge(format: 'csv')), class: 'btn btn-default') + += render 'shared/title', name: t(:account_activities) + +.row + .col-md-12 + = search_form_for @q, url: [:admin, :account_activities], html: { style: 'margin-bottom: 0;' } do |f| + .row + .col-md-12 + .form-group + = f.label t(:registrar) + = f.select :account_registrar_id_in, Registrar.all.map { |x| [x, x.id] }, {}, class: 'form-control js-combobox', placeholder: t(:choose), multiple: true + .row + .col-md-6 + .form-group + = f.label t(:activity_type) + = f.select :activity_type_in, AccountActivity.types_for_select, {}, class: 'form-control js-combobox', placeholder: t(:choose), multiple: true + .col-md-6 + .form-group + = f.label t(:description) + = f.search_field :description_cont, class: 'form-control', placeholder: t(:description), autocomplete: 'off' + .row + .col-md-3 + .form-group + = f.label t(:receipt_date_from) + = f.search_field :created_at_gteq, value: params[:q][:created_at_gteq], class: 'form-control datepicker', placeholder: t(:receipt_date_from), autocomplete: 'off' + .col-md-3 + .form-group + = f.label t(:receipt_date_until) + = f.search_field :created_at_lteq, value: params[:q][:created_at_lteq], class: 'form-control datepicker', placeholder: t(:receipt_date_until), autocomplete: 'off' + .col-md-6{style: 'padding-top: 25px;'} + %button.btn.btn-default.search +   + %span.glyphicon.glyphicon-search +   + %button.btn.btn-default.js-reset-form + = t(:clear_fields) +%hr + +.row + .col-md-12 + .table-responsive + %table.table.table-hover.table-condensed + %thead + %tr + %th{class: 'col-xs-2'} + = sort_link(@q, 'registrar') + %th{class: 'col-xs-3'} + = sort_link(@q, 'description') + %th{class: 'col-xs-2'} + = sort_link(@q, 'activity_type') + %th{class: 'col-xs-3'} + = sort_link(@q, 'created_at', t(:receipt_date)) + %th{class: 'col-xs-2'} + = sort_link(@q, 'sum') + %tbody + - @account_activities.each do |x| + %tr + %td= link_to(x.account.registrar.try(:code), admin_registrar_path(x.account.registrar)) + %td= x.description.present? ? x.description : '-' + %td= x.activity_type ? t(x.activity_type) : '' + %td= l(x.created_at) + - c = x.sum > 0.0 ? 'text-success' : 'text-danger' + - s = x.sum > 0.0 ? "+#{x.sum} #{x.currency}" : "#{x.sum} #{x.currency}" + %td{class: c}= s +.row + .col-md-12 + = paginate @account_activities + +:coffee + $(".js-reset-form").on "click", (e) -> + e.preventDefault(); + window.location = "#{admin_account_activities_path}" diff --git a/app/views/layouts/admin/application.haml b/app/views/layouts/admin/application.haml index d224b1464..6e3257740 100644 --- a/app/views/layouts/admin/application.haml +++ b/app/views/layouts/admin/application.haml @@ -55,6 +55,7 @@ %li= link_to t(:pricelists), admin_pricelists_path %li= link_to t(:bank_statements), admin_bank_statements_path %li= link_to t(:invoices), admin_invoices_path + %li= link_to t(:account_activities), admin_account_activities_path %li.divider %li.dropdown-header= t(:system) %li= link_to t(:settings), admin_settings_path diff --git a/config/locales/en.yml b/config/locales/en.yml index 5bd4c0f63..d99e55eb7 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -730,6 +730,7 @@ en: The domain name server is a computer that saves and forwards via a general-access data communications network such data that is connected with the domain name and corresponding IP addresses. Your IT helpdesk or Internet service provider will have the necessary information about the domain name servers. account_activity: 'Account activity' + account_activities: 'Account activities' receipt_date: 'Receipt date' manual_binding: 'Manual binding' transaction_is_already_binded: 'Transaction is already binded' diff --git a/config/routes.rb b/config/routes.rb index 5ea7beff7..24148befb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -161,6 +161,7 @@ Rails.application.routes.draw do resources :keyrelays resources :pricelists resources :mail_templates + resources :account_activities resources :bank_statements do resources :bank_transactions diff --git a/spec/features/admin/account_activity_spec.rb b/spec/features/admin/account_activity_spec.rb new file mode 100644 index 000000000..0101337b6 --- /dev/null +++ b/spec/features/admin/account_activity_spec.rb @@ -0,0 +1,45 @@ +require 'rails_helper' + +feature 'Account activity', type: :feature do + before :all do + @user = Fabricate(:admin_user) + r = Fabricate(:registrar) + Fabricate.times(5, :account_activity, account: r.cash_account) + Fabricate(:account_activity, account: r.cash_account, description: 'acc activity test', sum: -12) + end + + context 'as unknown user' do + it 'should redirect to sign in page' do + visit '/admin/account_activities' + current_path.should == '/admin/login' + page.should have_text('You need to sign in or sign up') + end + end + + context 'as signed in user' do + before do + sign_in @user + end + + it 'should navigate to account activities page' do + visit admin_account_activities_path + page.should have_text('+110.0 EUR', count: 5) + page.should have_text('-12.0 EUR') + end + + it 'should search activities by description' do + visit admin_account_activities_path + fill_in 'Description', with: 'test' + find('.btn.btn-default.search').click + page.should have_text('-12.0 EUR') + page.should_not have_text('+110.0 EUR') + end + + it 'should download csv' do + visit admin_account_activities_path + click_link 'Export CSV' + response_headers['Content-Type'].should == 'text/csv' + response_headers['Content-Disposition'].should match(/attachment; filename="account_activities_\d+\.csv"/) + end + end +end From b335b7d4428036763b8417060cf0fa399aca9507 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Thu, 10 Sep 2015 18:17:42 +0300 Subject: [PATCH 09/41] Remove comment #2893 --- app/controllers/admin/account_activities_controller.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/controllers/admin/account_activities_controller.rb b/app/controllers/admin/account_activities_controller.rb index 77e5535ce..1c447d8a6 100644 --- a/app/controllers/admin/account_activities_controller.rb +++ b/app/controllers/admin/account_activities_controller.rb @@ -3,7 +3,6 @@ class Admin::AccountActivitiesController < AdminController def index # rubocop: disable Metrics/AbcSize params[:q] ||= {} - # account = current_user.registrar.cash_account ca_cache = params[:q][:created_at_lteq] begin From 193986765acbc4b48183ef5d8f329367ad019fe5 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Fri, 11 Sep 2015 10:59:55 +0300 Subject: [PATCH 10/41] Add domain name to cronlog #2923 --- app/models/domain.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/models/domain.rb b/app/models/domain.rb index 10942ada3..5898d88be 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -215,7 +215,9 @@ class Domain < ActiveRecord::Base DomainMailer.pending_delete_expired_notification(domain).deliver_now end domain.clean_pendings! - STDOUT << "#{Time.zone.now.utc} Domain.clean_expired_pendings: ##{domain.id}\n" unless Rails.env.test? + unless Rails.env.test? + STDOUT << "#{Time.zone.now.utc} Domain.clean_expired_pendings: ##{domain.id} (#{domain.name})\n" + end end STDOUT << "#{Time.zone.now.utc} - Successfully cancelled #{count} domain pendings\n" unless Rails.env.test? count @@ -232,7 +234,7 @@ class Domain < ActiveRecord::Base domains.each do |domain| next unless domain.expirable? domain.set_graceful_expired - STDOUT << "#{Time.zone.now.utc} Domain.start_expire_period: ##{domain.id} #{domain.changes}\n" unless Rails.env.test? + STDOUT << "#{Time.zone.now.utc} Domain.start_expire_period: ##{domain.id} (#{domain.name}) #{domain.changes}\n" unless Rails.env.test? domain.save(validate: false) end @@ -246,7 +248,7 @@ class Domain < ActiveRecord::Base d.each do |domain| next unless domain.server_holdable? domain.statuses << DomainStatus::SERVER_HOLD - STDOUT << "#{Time.zone.now.utc} Domain.start_redemption_grace_period: ##{domain.id} #{domain.changes}\n" unless Rails.env.test? + STDOUT << "#{Time.zone.now.utc} Domain.start_redemption_grace_period: ##{domain.id} (#{domain.name}) #{domain.changes}\n" unless Rails.env.test? domain.save end @@ -260,7 +262,7 @@ class Domain < ActiveRecord::Base d.each do |domain| next unless domain.delete_candidateable? domain.statuses << DomainStatus::DELETE_CANDIDATE - STDOUT << "#{Time.zone.now.utc} Domain.start_delete_period: ##{domain.id} #{domain.changes}\n" unless Rails.env.test? + STDOUT << "#{Time.zone.now.utc} Domain.start_delete_period: ##{domain.id} (#{domain.name}) #{domain.changes}\n" unless Rails.env.test? domain.save end @@ -275,13 +277,13 @@ class Domain < ActiveRecord::Base c = 0 Domain.where("statuses @> '{deleteCandidate}'::varchar[]").each do |x| x.destroy - STDOUT << "#{Time.zone.now.utc} Domain.destroy_delete_candidates: by deleteCandidate ##{x.id}\n" unless Rails.env.test? + STDOUT << "#{Time.zone.now.utc} Domain.destroy_delete_candidates: by deleteCandidate ##{x.id} (#{x.name})\n" unless Rails.env.test? c += 1 end Domain.where('force_delete_at <= ?', Time.zone.now).each do |x| x.destroy - STDOUT << "#{Time.zone.now.utc} Domain.destroy_delete_candidates: by force delete time ##{x.id}\n" unless Rails.env.test? + STDOUT << "#{Time.zone.now.utc} Domain.destroy_delete_candidates: by force delete time ##{x.id} (#{x.name})\n" unless Rails.env.test? c += 1 end From 927f7625526ac18aecf4ced6372b4426f5f94e3c Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Fri, 11 Sep 2015 11:03:20 +0300 Subject: [PATCH 11/41] Add contact name to orphans cronlog #2923 --- app/models/contact.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/contact.rb b/app/models/contact.rb index 09552c636..a995e2f03 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -173,7 +173,7 @@ class Contact < ActiveRecord::Base unless Rails.env.test? orphans.each do |m| - STDOUT << "#{Time.zone.now.utc} Contact.destroy_orphans: ##{m.id}\n" + STDOUT << "#{Time.zone.now.utc} Contact.destroy_orphans: ##{m.id} (#{m.name})\n" end end From fca74e2ede1320584c3b9d38b9e451c0d73ae7c6 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Fri, 11 Sep 2015 12:10:48 +0300 Subject: [PATCH 12/41] Validate all contacts on domain create / update #2825 --- app/models/domain.rb | 3 +++ app/models/epp/domain.rb | 21 +++++++++++++++++---- config/locales/en.yml | 1 + spec/epp/domain_spec.rb | 2 +- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/app/models/domain.rb b/app/models/domain.rb index 5898d88be..1f57a7b8a 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -9,6 +9,7 @@ class Domain < ActiveRecord::Base belongs_to :registrar belongs_to :registrant + # TODO: should we user validates_associated :registrant here? has_many :admin_domain_contacts accepts_nested_attributes_for :admin_domain_contacts, allow_destroy: true @@ -271,6 +272,7 @@ class Domain < ActiveRecord::Base end # rubocop:disable Rails/FindEach + # rubocop:disable Metrics/AbcSize def destroy_delete_candidates STDOUT << "#{Time.zone.now.utc} - Destroying domains\n" unless Rails.env.test? @@ -289,6 +291,7 @@ class Domain < ActiveRecord::Base STDOUT << "#{Time.zone.now.utc} - Successfully destroyed #{c} domains\n" unless Rails.env.test? end + # rubocop: enable Metrics/AbcSize # rubocop:enable Rails/FindEach # rubocop: enable Metrics/LineLength end diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 5d54fb7d2..e38b5b150 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -9,11 +9,24 @@ class Epp::Domain < Domain false end - before_validation :validate_contacts + after_validation :validate_contacts def validate_contacts - return if contacts.map(&:valid?).all? - add_epp_error('2304', nil, nil, I18n.t(:object_status_prohibits_operation)) - false + ok = true + if new_record? + ac = admin_domain_contacts.map(&:contact) + tc = tech_domain_contacts.map(&:contact) + else + ac = contacts + tc = [] + end + # validate registrant here as well + ([registrant] + ac + tc).each do |x| + unless x.valid? + add_epp_error('2304', nil, nil, I18n.t(:contact_is_not_valid, value: x.code)) + ok = false + end + end + ok end before_save :link_contacts diff --git a/config/locales/en.yml b/config/locales/en.yml index d99e55eb7..7351623dc 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -918,3 +918,4 @@ en: mail_templates: Mail Templates new_mail_template: New mail template failure: "It was not saved" + contact_is_not_valid: 'Contact %{value} is not valid, please fix the invalid contact' diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index 0d24e2cfa..14b630308 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -1435,7 +1435,7 @@ describe 'EPP Domain', epp: true do original_contacts_codes.sort.should == domain.contacts.pluck(:code).sort end - fit 'transfers domain contact should populate copy_from_id' do + it 'transfers domain contact should populate copy_from_id' do d = Fabricate(:domain) d.tech_contacts << domain.registrant From a2b6409460d0a7996760d3cc010e6bafa0ad4a0e Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Fri, 11 Sep 2015 12:44:10 +0300 Subject: [PATCH 13/41] Refactor #2825 --- app/models/epp/domain.rb | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index e38b5b150..236adb786 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -12,13 +12,8 @@ class Epp::Domain < Domain after_validation :validate_contacts def validate_contacts ok = true - if new_record? - ac = admin_domain_contacts.map(&:contact) - tc = tech_domain_contacts.map(&:contact) - else - ac = contacts - tc = [] - end + ac = admin_domain_contacts.includes(:contact).select { |x| !x.marked_for_destruction? }.map(&:contact) + tc = tech_domain_contacts.includes(:contact).select { |x| !x.marked_for_destruction? }.map(&:contact) # validate registrant here as well ([registrant] + ac + tc).each do |x| unless x.valid? From 2ee65aa9507424682930c1673cc643f0dfe6ff08 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Fri, 11 Sep 2015 13:06:30 +0300 Subject: [PATCH 14/41] Add bullet workaround #2825 --- app/models/epp/domain.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 236adb786..34d0e01e3 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -12,8 +12,13 @@ class Epp::Domain < Domain after_validation :validate_contacts def validate_contacts ok = true - ac = admin_domain_contacts.includes(:contact).select { |x| !x.marked_for_destruction? }.map(&:contact) - tc = tech_domain_contacts.includes(:contact).select { |x| !x.marked_for_destruction? }.map(&:contact) + active_admins = admin_domain_contacts.select { |x| !x.marked_for_destruction? } + active_techs = tech_domain_contacts.select { |x| !x.marked_for_destruction? } + + # bullet workaround + ac = active_admins.map { |x| Contact.find(x.contact_id) } + tc = active_techs.map { |x| Contact.find(x.contact_id) } + # validate registrant here as well ([registrant] + ac + tc).each do |x| unless x.valid? From 1af554a9a0d326e6dd4476259ed95ebb6e8c892a Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Fri, 11 Sep 2015 14:28:06 +0300 Subject: [PATCH 15/41] Ensure database order for domain spec --- spec/epp/domain_spec.rb | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index 14b630308..920f18690 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -1299,7 +1299,7 @@ describe 'EPP Domain', epp: true do x.registrar_id.should == @registrar2.id end - new_contact = Contact.last + new_contact = Contact.last(2).sort.last # ensure fixed order new_contact.name.should == old_contact.name # there should be 2 references to the new contact @@ -1353,13 +1353,10 @@ describe 'EPP Domain', epp: true do x.registrar_id.should == @registrar2.id end - new_contact, new_contact_2 = Contact.last(2) + new_contact, new_contact_2 = Contact.last(2).sort - # database does not follow always same order, thus we swap object when different order - new_contact, new_contact_2 = new_contact_2, new_contact if new_contact.name != 'first' - - new_contact.name.should == old_contact.name - new_contact_2.name.should == old_contact_2.name + new_contact.name.should == 'first' + new_contact_2.name.should == 'second' # there should be 2 references to the new contact (admin + tech) domain.domain_contacts.where(contact_id: new_contact.id).count.should == 2 From 2b34d619b52538df992ae1bb7d7f89c2fb3d6ea3 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Fri, 11 Sep 2015 16:57:02 +0300 Subject: [PATCH 16/41] Add email sending on force delete #2881 --- app/mailers/domain_mailer.rb | 41 ++++++---- app/models/domain.rb | 1 + .../domain_mailer/force_delete.html.erb | 76 +++++++++++++++++++ .../domain_mailer/force_delete.text.erb | 63 +++++++++++++++ config/locales/en.yml | 1 + 5 files changed, 167 insertions(+), 15 deletions(-) create mode 100644 app/views/mailers/domain_mailer/force_delete.html.erb create mode 100644 app/views/mailers/domain_mailer/force_delete.text.erb diff --git a/app/mailers/domain_mailer.rb b/app/mailers/domain_mailer.rb index 8544af6a7..a8c79f66d 100644 --- a/app/mailers/domain_mailer.rb +++ b/app/mailers/domain_mailer.rb @@ -20,7 +20,7 @@ class DomainMailer < ApplicationMailer return if whitelist_blocked?(@old_registrant.email) mail(to: format(@old_registrant.email), - subject: "#{I18n.t(:pending_update_request_for_old_registrant_subject, + subject: "#{I18n.t(:pending_update_request_for_old_registrant_subject, name: @domain.name)} [#{@domain.name}]") end @@ -43,7 +43,7 @@ class DomainMailer < ApplicationMailer return if whitelist_blocked?(@new_registrant.email) mail(to: format(@new_registrant.email), - subject: "#{I18n.t(:pending_update_notification_for_new_registrant_subject, + subject: "#{I18n.t(:pending_update_notification_for_new_registrant_subject, name: @domain.name)} [#{@domain.name}]") end @@ -53,19 +53,19 @@ class DomainMailer < ApplicationMailer return if whitelist_blocked?(@domain.registrant_email) mail(to: format(@domain.registrant_email), - subject: "#{I18n.t(:registrant_updated_notification_for_new_registrant_subject, + subject: "#{I18n.t(:registrant_updated_notification_for_new_registrant_subject, name: @domain.name)} [#{@domain.name}]") end def registrant_updated_notification_for_old_registrant(domain) @domain = domain return if delivery_off?(@domain) - + @old_registrant_email = domain.registrant_email # Nb! before applying pending updates return if whitelist_blocked?(@old_registrant_email) mail(to: format(@old_registrant_email), - subject: "#{I18n.t(:registrant_updated_notification_for_old_registrant_subject, + subject: "#{I18n.t(:registrant_updated_notification_for_old_registrant_subject, name: @domain.name)} [#{@domain.name}]") end @@ -73,12 +73,12 @@ class DomainMailer < ApplicationMailer @domain = domain # no delivery off control, driggered by que, no epp request - @new_registrant_email = @domain.pending_json['new_registrant_email'] - @new_registrant_name = @domain.pending_json['new_registrant_name'] + @new_registrant_email = @domain.pending_json['new_registrant_email'] + @new_registrant_name = @domain.pending_json['new_registrant_name'] return if whitelist_blocked?(@new_registrant_email) mail(to: format(@new_registrant_email), - subject: "#{I18n.t(:pending_update_rejected_notification_for_new_registrant_subject, + subject: "#{I18n.t(:pending_update_rejected_notification_for_new_registrant_subject, name: @domain.name)} [#{@domain.name}]") end @@ -86,8 +86,8 @@ class DomainMailer < ApplicationMailer @domain = domain # no delivery off control, driggered by cron, no epp request - @new_registrant_email = @domain.pending_json['new_registrant_email'] - @new_registrant_name = @domain.pending_json['new_registrant_name'] + @new_registrant_email = @domain.pending_json['new_registrant_email'] + @new_registrant_name = @domain.pending_json['new_registrant_name'] return if whitelist_blocked?(@new_registrant_email) if @new_registrant_email.blank? @@ -95,7 +95,7 @@ class DomainMailer < ApplicationMailer return end mail(to: format(@new_registrant_email), - subject: "#{I18n.t(:pending_update_expired_notification_for_new_registrant_subject, + subject: "#{I18n.t(:pending_update_expired_notification_for_new_registrant_subject, name: @domain.name)} [#{@domain.name}]") end @@ -120,7 +120,7 @@ class DomainMailer < ApplicationMailer return if whitelist_blocked?(@old_registrant.email) mail(to: format(@old_registrant.email), - subject: "#{I18n.t(:domain_pending_deleted_subject, + subject: "#{I18n.t(:domain_pending_deleted_subject, name: @domain.name)} [#{@domain.name}]") end @@ -140,7 +140,7 @@ class DomainMailer < ApplicationMailer return if whitelist_blocked?(@domain.registrant.email) mail(to: format(@domain.registrant.email), - subject: "#{I18n.t(:pending_delete_rejected_notification_subject, + subject: "#{I18n.t(:pending_delete_rejected_notification_subject, name: @domain.name)} [#{@domain.name}]") end @@ -150,7 +150,7 @@ class DomainMailer < ApplicationMailer return if whitelist_blocked?(@domain.registrant.email) mail(to: format(@domain.registrant.email), - subject: "#{I18n.t(:pending_delete_expired_notification_subject, + subject: "#{I18n.t(:pending_delete_expired_notification_subject, name: @domain.name)} [#{@domain.name}]") end @@ -159,7 +159,18 @@ class DomainMailer < ApplicationMailer return if whitelist_blocked?(@domain.registrant.email) mail(to: format(@domain.registrant.email), - subject: "#{I18n.t(:delete_confirmation_subject, + subject: "#{I18n.t(:delete_confirmation_subject, name: @domain.name)} [#{@domain.name}]") end + + def force_delete(domain) + @domain = domain + emails = ([@domain.registrant.email] + @domain.admin_contacts.map { |x| format(x.email) }).uniq + return if whitelist_blocked?(emails) + + formatted_emails = emails.map { |x| format(x) } + mail(to: formatted_emails, + subject: "#{I18n.t(:force_delete_subject)}" + ) + end end diff --git a/app/models/domain.rb b/app/models/domain.rb index 1f57a7b8a..1ea6a1cc6 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -591,6 +591,7 @@ class Domain < ActiveRecord::Base registrar.messages.create!( body: I18n.t('force_delete_set_on_domain', domain: name) ) + DomainMailer.force_delete(self).deliver_now return true end false diff --git a/app/views/mailers/domain_mailer/force_delete.html.erb b/app/views/mailers/domain_mailer/force_delete.html.erb new file mode 100644 index 000000000..e7ab0317f --- /dev/null +++ b/app/views/mailers/domain_mailer/force_delete.html.erb @@ -0,0 +1,76 @@ + + +
+

Eesti Interneti Sihtasutus

+
+ + +
+
+ +Lugupeetud domeeni <%= @domain.name %> kontaktisik + +

Eesti Interneti SA (EIS) domeeniregistrisse on domeeni <%= @domain.name %> kohta kantud järgmised andmed:

+ +

Registreerija nimi: <%= @domain.registrant %>
+Registrikood: <%= @domain.registrant.try(:ident) %>

+ +

EIS-le on saanud teatavaks, et juriidiline isik registrikoodiga <%= @domain.registrant.try(:ident) %> on äriregistrist kustutatud.

+ +

Kuivõrd äriregistrist kustutatud juriidiline isik ei saa olla domeeni registreerijaks, siis algatas EIS <%= l(Time.zone.now, format: :date) %> vastavalt Domeenireeglite (http://www.internet.ee/et/domeenid/) punktile 6.4 domeeni <%= @domain.name %> suhtes 30 päeva pikkuse kustutusmenetluse. Kustutamise käigus jääb domeen internetis kättesaadavaks.

+ +

Domeenireeglite punktist 6.4 tulenevalt on domeeni suhtes õigust omaval registreerijal võimalus esitada domeeni <%= @domain.name %> registripidajale <%= @domain.registrar %> domeeni üleandmise taotlus Domeenireeglite p 5.3.6.2 kohaselt. Taotlusele tuleb lisada domeeni omandamist tõendavad dokumendid, mis asendavad Domeenireeglite punktis 5.3.6.3 sätestatud üleandva registreerija nõusolekut. Vastav dokumentatsioon tuleks esitada Registripidajale esimesel võimalusel.

+ +

Kui üleandmine ei ole 30 päeva jooksul toimunud, kustub domeen <%= @domain.name %> 24 tunni jooksul <%= l(@domain.force_delete_at, format: :short) %> möödumisest juhuslikult valitud ajahetkel. Soovi korral on võimalik domeen pärast selle kustumist registrist “kes ees, see mees” põhimõttel uuesti registreerida.

+ +

Lisaküsimuste korral võtke palun ühendust oma registripidajaga <%= @domain.registrar %>, kelle kontaktandmed leiate lingilt http://www.internet.ee/registripidajad



+ + + +Dear contact of <%= @domain.name %> domain + +

The following details for domain name <%= @domain.name %> have been entered into the Estonian Internet Foundation's (EIF) domain registry:

+ +

Registrant's name: <%= @domain.registrant %>
+Registry code: <%= @domain.registrant.try(:ident) %>

+ +

EIF has learned that the legal person with registry code <%= @domain.registrant.try(:ident) %> has been deleted from the Business Registry.

+ +

As a terminated legal person cannot be the registrant of a domain, the EIF started the deletion process of <%= @domain.name %> domain on <%= l(Time.zone.now, format: :date) %> according to the Domain Regulation (http://www.internet.ee/en/domains/), using the 30-day delete procedure. The domain will remain available on the Internet during the delete procedure.

+ +

According to paragraph 6.4 of the Domain Regulation, the registrant holding a right to the domain name <%= @domain.name %> can submit a domain name transfer application to the registrar <%= @domain.registrar %> in accordance with paragraph 5.3.6.2 of the Domain Regulation. The application must be submitted together with documents certifying the acquisition of the domain that will replace the consent of the surrendering registrant as laid down in paragraph 5.3.6.3 of the Domain Regulation. The relevant documents should be submitted to the registrar as soon as possible.

+ +

If the transfer has not been made in 30 days, the domain <%= @domain.name %> will be deleted at a randomly chosen moment within 24 hours after <%= l(@domain.force_delete_at, format: :short) %>. After deletion it is possible to reregister the domain on a "first come, first served" basis.

+ +

Should you have additional questions, please contact your registrar <%= @domain.registrar %>, whose contact information can be found at http://www.internet.ee/en/registrars/



+ + + +Уважаемое контактное лицо домена <%= @domain.name %> + +

В регистр доменов Целевого учреждения Eesti Internet (EIS) внесены следующие данные относительно домена <%= @domain.name %>:

+ +

Имя регистранта: <%= @domain.registrant %>
+Регистрационный код: <%= @domain.registrant.try(:ident) %>

+ +

EIS стало известно, что юридическое лицо с регистрационным кодом <%= @domain.registrant.try(:ident) %> удалено из коммерческого реестра.

+ +

Поскольку прекратившее деятельность юридическое лицо не может являться регистрантом домена, то согласно пункту 6.4 Правил домена (http://www.internet.ee/ru/11364/11400/) EIS <%= l(Time.zone.now, format: :date) %> инициировало удаление домена <%= @domain.name %> с применением 30-дневной процедуры удаления. На протяжении процесса удаления домен остается доступным в Интернете.

+ +

Согласно пункту 6.4 Правил домена регистрант, имеющий право на домен, может подать регистратору <%= @domain.registrar %> домена <%= @domain.name %> ходатайство о передаче домена в соответствии с п. 5.3.6.2 Правил домена. К ходатайству следует приложить подтверждающие приобретение домена документы, заменяющие в соответствии с пунктом 5.3.6.3 Правил домена согласие передающего доменное имя регистранта. EIS предлагает представить соответствующую документацию Регистратору при первой возможности, начиная с инициирования процедуры удаления.

+ +

Если в течение 30 дней передача не произошла, домен <%= @domain.name %> удаляется по истечении 24 часов <%= l(@domain.force_delete_at, format: :short) %> в случайный момент времени. По желанию после удаления из регистра домен можно снова зарегистрировать по принципу "кто успел, тот и съел".

+ +

Просим обратиться к своему регистратору <%= @domain.registrar %>. Контактные данные регистраторов можно найти по адресу http://www.internet.ee/ru/p/



+ + + + +
+

Lugupidamisega,
+ Yours Sincerely,
+ С уважением,

+

Eesti Interneti SA
+ Estonian Internet Foundation

+
+
diff --git a/app/views/mailers/domain_mailer/force_delete.text.erb b/app/views/mailers/domain_mailer/force_delete.text.erb new file mode 100644 index 000000000..fdd075647 --- /dev/null +++ b/app/views/mailers/domain_mailer/force_delete.text.erb @@ -0,0 +1,63 @@ +Lugupeetud domeeni <%= @domain.name %> kontaktisik + +Eesti Interneti SA (EIS) domeeniregistrisse on domeeni <%= @domain.name %> kohta kantud järgmised andmed: + +Registreerija nimi: <%= @domain.registrant %> +Registrikood: <%= @domain.registrant.try(:ident) %> + +EIS-le on saanud teatavaks, et juriidiline isik registrikoodiga <%= @domain.registrant.try(:ident) %> on äriregistrist kustutatud. + +Kuivõrd äriregistrist kustutatud juriidiline isik ei saa olla domeeni registreerijaks, siis algatas EIS <%= l(Time.zone.now, format: :date) %> vastavalt Domeenireeglite (http://www.internet.ee/et/domeenid/) punktile 6.4 domeeni <%= @domain.name %> suhtes 30 päeva pikkuse kustutusmenetluse. Kustutamise käigus jääb domeen internetis kättesaadavaks. + +Domeenireeglite punktist 6.4 tulenevalt on domeeni suhtes õigust omaval registreerijal võimalus esitada domeeni <%= @domain.name %> registripidajale <%= @domain.registrar %> domeeni üleandmise taotlus Domeenireeglite p 5.3.6.2 kohaselt. Taotlusele tuleb lisada domeeni omandamist tõendavad dokumendid, mis asendavad Domeenireeglite punktis 5.3.6.3 sätestatud üleandva registreerija nõusolekut. Vastav dokumentatsioon tuleks esitada Registripidajale esimesel võimalusel. + +Kui üleandmine ei ole 30 päeva jooksul toimunud, kustub domeen <%= @domain.name %> 24 tunni jooksul <%= l(@domain.force_delete_at, format: :short) %> möödumisest juhuslikult valitud ajahetkel. Soovi korral on võimalik domeen pärast selle kustumist registrist "kes ees, see mees" põhimõttel uuesti registreerida. + +Lisaküsimuste korral võtke palun ühendust oma registripidajaga <%= @domain.registrar %>, kelle kontaktandmed leiate lingilt http://www.internet.ee/et/registripidajad/ + + + +Dear contact of <%= @domain.name %> domain + +The following details for domain name <%= @domain.name %> have been entered into the Estonian Internet Foundation's (EIF) domain registry: + +Registrant's name: <%= @domain.registrant %> +Registry code: <%= @domain.registrant.try(:ident) %> + +EIF has learned that the legal person with registry code <%= @domain.registrant.try(:ident) %> has been deleted from the Business Registry. + +As a terminated legal person cannot be the registrant of a domain, the EIF started the deletion process of <%= @domain.name %> domain on <%= l(Time.zone.now, format: :date) %> according to the Domain Regulation (http://www.internet.ee/en/domains/), using the 30-day delete procedure. The domain will remain available on the Internet during the delete procedure. + +According to paragraph 6.4 of the Domain Regulation, the registrant holding a right to the domain name <%= @domain.name %> can submit a domain name transfer application to the registrar <%= @domain.registrar %> in accordance with paragraph 5.3.6.2 of the Domain Regulation. The application must be submitted together with documents certifying the acquisition of the domain that will replace the consent of the surrendering registrant as laid down in paragraph 5.3.6.3 of the Domain Regulation. The relevant documents should be submitted to the registrar as soon as possible. + +If the transfer has not been made in 30 days, the domain <%= @domain.name %> will be deleted at a randomly chosen moment within 24 hours after <%= l(@domain.force_delete_at, format: :short) %>. After deletion it is possible to reregister the domain on a "first come, first served" basis. + +Should you have additional questions, please contact your registrar <%= @domain.registrar %>, whose contact information can be found at http://www.internet.ee/en/registrars/ + + + +Уважаемое контактное лицо домена <%= @domain.name %> + +В регистр доменов Целевого учреждения Eesti Internet (EIS) внесены следующие данные относительно домена <%= @domain.name %>: + +Имя регистранта: <%= @domain.registrant %> +Регистрационный код: <%= @domain.registrant.try(:ident) %> + +EIS стало известно, что юридическое лицо с регистрационным кодом <%= @domain.registrant.try(:ident) %> удалено из коммерческого реестра. + +Поскольку прекратившее деятельность юридическое лицо не может являться регистрантом домена, то согласно пункту 6.4 Правил домена (http://www.internet.ee/ru/11364/11400/) EIS <%= l(Time.zone.now, format: :date) %> инициировало удаление домена <%= @domain.name %> с применением 30-дневной процедуры удаления. На протяжении процесса удаления домен остается доступным в Интернете. + +Согласно пункту 6.4 Правил домена регистрант, имеющий право на домен, может подать регистратору <%= @domain.registrar %> домена <%= @domain.name %> ходатайство о передаче домена в соответствии с п. 5.3.6.2 Правил домена. К ходатайству следует приложить подтверждающие приобретение домена документы, заменяющие в соответствии с пунктом 5.3.6.3 Правил домена согласие передающего доменное имя регистранта. EIS предлагает представить соответствующую документацию Регистратору при первой возможности, начиная с инициирования процедуры удаления. + +Если в течение 30 дней передача не произошла, домен <%= @domain.name %> удаляется по истечении 24 часов <%= l(@domain.force_delete_at, format: :short) %> в случайный момент времени. По желанию после удаления из регистра домен можно снова зарегистрировать по принципу "кто успел, тот и съел". + +Просим обратиться к своему регистратору <%= @domain.registrar %>. Контактные данные регистраторов можно найти по адресу http://www.internet.ee/ru/p/ + + + +Lugupidamisega, +Yours Sincerely, +С уважением, +--- +Eesti Interneti SA +Estonian Internet Foundation diff --git a/config/locales/en.yml b/config/locales/en.yml index 7351623dc..6b9151e5b 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -919,3 +919,4 @@ en: new_mail_template: New mail template failure: "It was not saved" contact_is_not_valid: 'Contact %{value} is not valid, please fix the invalid contact' + force_delete_subject: 'Kustutusmenetluse teade' From 72c3f38f4e270c20ece10de1a9a736e462e36e31 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Fri, 11 Sep 2015 17:10:54 +0300 Subject: [PATCH 17/41] Remove image from force delete letter #2881 --- app/views/mailers/domain_mailer/force_delete.html.erb | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/views/mailers/domain_mailer/force_delete.html.erb b/app/views/mailers/domain_mailer/force_delete.html.erb index e7ab0317f..4a6dd3c9f 100644 --- a/app/views/mailers/domain_mailer/force_delete.html.erb +++ b/app/views/mailers/domain_mailer/force_delete.html.erb @@ -1,7 +1,4 @@ -
-

Eesti Interneti Sihtasutus

-
From edcd63a9ff0172bd61d12c588ff7d1c6474df5a3 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Fri, 11 Sep 2015 17:12:55 +0300 Subject: [PATCH 18/41] Improve html #2881 --- app/views/mailers/domain_mailer/force_delete.html.erb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/views/mailers/domain_mailer/force_delete.html.erb b/app/views/mailers/domain_mailer/force_delete.html.erb index 4a6dd3c9f..5dac0d3b4 100644 --- a/app/views/mailers/domain_mailer/force_delete.html.erb +++ b/app/views/mailers/domain_mailer/force_delete.html.erb @@ -1,4 +1,7 @@ +
+

Eesti Interneti Sihtasutus

+
From ae29585ae2c27e745e28acba062ede0358872d8a Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Fri, 11 Sep 2015 18:09:14 +0300 Subject: [PATCH 19/41] Honor database order for domain spec --- spec/epp/domain_spec.rb | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index 920f18690..a3efb30da 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -1264,24 +1264,24 @@ describe 'EPP Domain', epp: true do end it 'transfers domain when domain contacts are some other domain contacts' do - old_contact = Fabricate(:contact, registrar: @registrar1) + old_contact = Fabricate(:contact, registrar: @registrar1, name: 'old name') domain.tech_contacts << old_contact domain.admin_contacts << old_contact d = Fabricate(:domain) d.tech_contacts << old_contact d.admin_contacts << old_contact + original_oc_id = domain.registrant.id original_contact_count = Contact.count original_domain_contact_count = DomainContact.count - pw = domain.auth_info - xml = domain_transfer_xml({ - name: { value: domain.name }, - authInfo: { pw: { value: pw } } - }) - login_as :registrar2 do + pw = domain.auth_info + xml = domain_transfer_xml({ + name: { value: domain.name }, + authInfo: { pw: { value: pw } } + }) response = epp_plain_request(xml) response[:msg].should == 'Command completed successfully' response[:result_code].should == '1000' @@ -1299,8 +1299,8 @@ describe 'EPP Domain', epp: true do x.registrar_id.should == @registrar2.id end - new_contact = Contact.last(2).sort.last # ensure fixed order - new_contact.name.should == old_contact.name + new_contact = Contact.last(4).detect { |c| c.name == 'old name' } # database order + new_contact.name.should == 'old name' # there should be 2 references to the new contact domain.domain_contacts.where(contact_id: new_contact.id).count.should == 2 @@ -1353,7 +1353,8 @@ describe 'EPP Domain', epp: true do x.registrar_id.should == @registrar2.id end - new_contact, new_contact_2 = Contact.last(2).sort + new_contact = Contact.last(5).detect { |c| c.name == 'first' } + new_contact_2 = Contact.last(5).detect { |c| c.name == 'second' } new_contact.name.should == 'first' new_contact_2.name.should == 'second' From 27f37b9ec4a07d74fe518b7c81fbedaea80bae35 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Tue, 15 Sep 2015 11:49:18 +0300 Subject: [PATCH 20/41] Add registrar dashboard #2713 --- .../registrar/dashboard_controller.rb | 17 +++++++ .../registrar/domains_controller.rb | 4 +- app/controllers/registrar/polls_controller.rb | 32 +++++++------ .../registrar/sessions_controller.rb | 32 +++++-------- .../registrar/xml_consoles_controller.rb | 5 +- app/controllers/registrar_controller.rb | 18 +++++--- app/models/ability.rb | 46 ++++++++++++------- app/views/layouts/registrar/application.haml | 2 +- app/views/registrar/dashboard/show.haml | 3 ++ config/locales/en.yml | 1 + config/routes.rb | 4 +- 11 files changed, 100 insertions(+), 64 deletions(-) create mode 100644 app/controllers/registrar/dashboard_controller.rb create mode 100644 app/views/registrar/dashboard/show.haml diff --git a/app/controllers/registrar/dashboard_controller.rb b/app/controllers/registrar/dashboard_controller.rb new file mode 100644 index 000000000..a2364e973 --- /dev/null +++ b/app/controllers/registrar/dashboard_controller.rb @@ -0,0 +1,17 @@ +class Registrar::DashboardController < RegistrarController + authorize_resource class: false + + def show + if can?(:show, :poll) + redirect_to registrar_poll_url and return + elsif can?(:show, Invoice) + redirect_to registrar_invoices_url and return + end + + # if current_user.try(:roles) == ['billing'] + # redirect_to registrar_invoices_url and return + # elsif can?(:show, :poll) + # redirect_to registrar_poll_url and return + # end + end +end diff --git a/app/controllers/registrar/domains_controller.rb b/app/controllers/registrar/domains_controller.rb index c6595cb03..374f09d4a 100644 --- a/app/controllers/registrar/domains_controller.rb +++ b/app/controllers/registrar/domains_controller.rb @@ -46,7 +46,7 @@ class Registrar::DomainsController < Registrar::DeppController # EPP controller # rubocop: enable Metrics/AbcSize def info - authorize! :view, Depp::Domain + authorize! :info, Depp::Domain @data = @domain.info(params[:domain_name]) if params[:domain_name] if response_ok? render 'info' @@ -57,7 +57,7 @@ class Registrar::DomainsController < Registrar::DeppController # EPP controller end def check - authorize! :view, Depp::Domain + authorize! :check, Depp::Domain if params[:domain_name] @data = @domain.check(params[:domain_name]) render 'check_index' and return unless response_ok? diff --git a/app/controllers/registrar/polls_controller.rb b/app/controllers/registrar/polls_controller.rb index 9dd284512..76e574e95 100644 --- a/app/controllers/registrar/polls_controller.rb +++ b/app/controllers/registrar/polls_controller.rb @@ -1,13 +1,14 @@ class Registrar::PollsController < Registrar::DeppController # EPP controller + authorize_resource class: false before_action :init_epp_xml def show - authorize! :view, :registrar_dashboard + # authorize! :view, :registrar_dashboard @data = depp_current_user.request(@ex.poll) end def destroy - authorize! :delete, :registrar_poll + # authorize! :delete, :registrar_poll @data = depp_current_user.request(@ex.poll(poll: { value: '', attrs: { op: 'ack', msgID: params[:id] } })) @@ -18,22 +19,23 @@ class Registrar::PollsController < Registrar::DeppController # EPP controller render 'show' end - def confirm_keyrelay - authorize! :confirm, :keyrelay - domain_params = params[:domain] - @data = @domain.confirm_keyrelay(domain_params) + # TODO: Keyrelay is disabled for now + # def confirm_keyrelay + # authorize! :confirm, :keyrelay + # domain_params = params[:domain] + # @data = @domain.confirm_keyrelay(domain_params) - if response_ok? - redirect_to info_registrar_domains_url(domain_name: domain_params[:name]) - else - @results = @data.css('result') - @data = depp_current_user.request(@ex.poll) - render 'show' - end - end + # if response_ok? + # redirect_to info_registrar_domains_url(domain_name: domain_params[:name]) + # else + # @results = @data.css('result') + # @data = depp_current_user.request(@ex.poll) + # render 'show' + # end + # end def confirm_transfer - authorize! :confirm, :transfer + # authorize! :confirm, :transfer domain_params = params[:domain] @data = @domain.confirm_transfer(domain_params) diff --git a/app/controllers/registrar/sessions_controller.rb b/app/controllers/registrar/sessions_controller.rb index b28dfdcf0..198860f49 100644 --- a/app/controllers/registrar/sessions_controller.rb +++ b/app/controllers/registrar/sessions_controller.rb @@ -47,10 +47,10 @@ class Registrar::SessionsController < Devise::SessionsController end end - if @depp_user.errors.none? && @depp_user.valid? + if @depp_user.errors.none? if @api_user.active? sign_in @api_user - redirect_to role_base_root_url(@api_user) + redirect_to registrar_root_url else @depp_user.errors.add(:base, :not_active) render 'login' @@ -71,17 +71,17 @@ class Registrar::SessionsController < Devise::SessionsController redirect_to :back and return end - if @api_user.can?(:create, :epp_login) - unless @api_user.registrar.api_ip_white?(request.ip) - flash[:alert] = I18n.t(:ip_is_not_whitelisted) - redirect_to :back and return - end - end + # if @api_user.can?(:create, :epp_login) + # unless @api_user.registrar.api_ip_white?(request.ip) + # flash[:alert] = I18n.t(:ip_is_not_whitelisted) + # redirect_to :back and return + # end + # end end sign_in @api_user if @api_user.identity_code == current_user.identity_code - redirect_to :back + redirect_to registrar_root_url end # rubocop:enable Metrics/CyclomaticComplexity # rubocop:enable Metrics/PerceivedComplexity @@ -91,7 +91,7 @@ class Registrar::SessionsController < Devise::SessionsController if @user sign_in(@user, event: :authentication) - redirect_to role_base_root_url(@user) + redirect_to registrar_root_url else flash[:alert] = t('no_such_user') redirect_to registrar_login_url @@ -111,7 +111,7 @@ class Registrar::SessionsController < Devise::SessionsController if Rails.env.test? && phone == "123" @user = ApiUser.find_by(identity_code: "14212128025") sign_in(@user, event: :authentication) - return redirect_to role_base_root_url(@user) + return redirect_to registrar_root_url end # country_codes = {'+372' => 'EST'} @@ -159,7 +159,7 @@ class Registrar::SessionsController < Devise::SessionsController sign_in @user flash[:notice] = t(:welcome) flash.keep(:notice) - render js: "window.location = '#{role_base_root_url(@user)}'" + render js: "window.location = '#{registrar_root_url}'" when 'NOT_VALID' render json: { message: t(:user_signature_is_invalid) }, status: :bad_request when 'EXPIRED_TRANSACTION' @@ -196,12 +196,4 @@ class Registrar::SessionsController < Devise::SessionsController return if WhiteIp.registrar_ip_white?(request.ip) render text: t('access_denied') and return end - - def role_base_root_url(user) - if user.try(:roles) == ['billing'] - registrar_invoices_url - else - registrar_root_url - end - end end diff --git a/app/controllers/registrar/xml_consoles_controller.rb b/app/controllers/registrar/xml_consoles_controller.rb index 83c20383b..31ec3eafc 100644 --- a/app/controllers/registrar/xml_consoles_controller.rb +++ b/app/controllers/registrar/xml_consoles_controller.rb @@ -1,10 +1,10 @@ class Registrar::XmlConsolesController < Registrar::DeppController # EPP controller + authorize_resource class: false + def show - authorize! :view, :registrar_xml_console end def create - authorize! :create, :registrar_xml_console begin @result = depp_current_user.server.request(params[:payload]) rescue @@ -14,7 +14,6 @@ class Registrar::XmlConsolesController < Registrar::DeppController # EPP control end def load_xml - authorize! :create, :registrar_xml_console cl_trid = "#{depp_current_user.tag}-#{Time.zone.now.to_i}" xml_dir_path = Rails.root + 'app/views/registrar/xml_consoles/epp_requests' xml = File.read("#{xml_dir_path}/#{params[:obj]}/#{params[:epp_action]}.xml") diff --git a/app/controllers/registrar_controller.rb b/app/controllers/registrar_controller.rb index a665cee09..f70b82849 100644 --- a/app/controllers/registrar_controller.rb +++ b/app/controllers/registrar_controller.rb @@ -17,15 +17,15 @@ class RegistrarController < ApplicationController sign_out(current_user) return end - return if Rails.env.development? + # return if Rails.env.development? registrar_ip_whitelisted = current_user.registrar.registrar_ip_white?(request.ip) - api_ip_whitelisted = true - if current_user.can?(:create, :epp_request) - api_ip_whitelisted = current_user.registrar.api_ip_white?(request.ip) - end + # api_ip_whitelisted = true + # if current_user.can?(:create, :epp_request) + # api_ip_whitelisted = current_user.registrar.api_ip_white?(request.ip) + # end - return if registrar_ip_whitelisted && api_ip_whitelisted + return if registrar_ip_whitelisted # && api_ip_whitelisted flash[:alert] = t('ip_is_not_whitelisted') sign_out(current_user) redirect_to registrar_login_path and return @@ -37,4 +37,10 @@ class RegistrarController < ApplicationController def head_title_sufix t(:registrar_head_title_sufix) end + + private + + def current_ability + @current_ability ||= Ability.new(current_user, request.remote_ip) + end end diff --git a/app/models/ability.rb b/app/models/ability.rb index 2c85cf8aa..bb120dc2f 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -4,7 +4,8 @@ class Ability # rubocop: disable Metrics/PerceivedComplexity # rubocop: disable Metrics/LineLength # rubocop: disable Metrics/AbcSize - def initialize(user) + def initialize(user, ip = nil) + @ip = ip alias_action :show, to: :view alias_action :show, :create, :update, :destroy, to: :crud @@ -35,14 +36,27 @@ class Ability end def epp # Registrar/api_user dynamic role - static_registrar + # static_registrar + can :view, :registrar_dashboard + + if @user.registrar.api_ip_white?(@ip) + can :manage, :poll + can :manage, Depp::Contact + # can :manage, Depp::Domain + # can :renew, Depp::Domain + # can :transfer, Depp::Domain + # can :manage, Depp::Keyrelay # TODO: Keyrelay is disabled for now + # can :confirm, :keyrelay # TODO: Keyrelay is disabled for now + can :manage, :xml_console + can :manage, Depp::Domain + end # REPP can(:manage, :repp) # EPP - can(:create, :epp_login) # billing can establis epp connection in order to login - can(:create, :epp_request) + can(:create, :epp_login) # billing can establish epp connection in order to login + # can(:create, :epp_request) # Epp::Domain can(:info, Epp::Domain) { |d, pw| d.registrar_id == @user.registrar_id || pw.blank? ? true : d.auth_info == pw } @@ -70,7 +84,7 @@ class Ability can(:manage, Invoice) { |i| i.buyer_id == @user.registrar_id } can :manage, :deposit can :read, AccountActivity - can(:create, :epp_login) # billing can establis epp connection in order to login + #can(:create, :epp_login) # billing can establis epp connection in order to login end def customer_service # Admin/admin_user dynamic role @@ -112,17 +126,17 @@ class Ability # Static roles, linked from dynamic roles # def static_registrar - can :manage, Nameserver - can :view, :registrar_dashboard - can :delete, :registrar_poll - can :manage, :registrar_xml_console - can :manage, Depp::Contact - can :manage, Depp::Domain - can :renew, Depp::Domain - can :transfer, Depp::Domain - can :manage, Depp::Keyrelay - can :confirm, :keyrelay - can :confirm, :transfer + #can :manage, Nameserver + # can :view, :registrar_dashboard + # can :delete, :registrar_poll + # can :manage, :registrar_xml_console + # can :manage, Depp::Contact + # can :manage, Depp::Domain + # can :renew, Depp::Domain + # can :transfer, Depp::Domain + # can :manage, Depp::Keyrelay + # can :confirm, :keyrelay + # can :confirm, :transfer end def static_registrant diff --git a/app/views/layouts/registrar/application.haml b/app/views/layouts/registrar/application.haml index 3754cd0bf..df936bbee 100644 --- a/app/views/layouts/registrar/application.haml +++ b/app/views/layouts/registrar/application.haml @@ -44,7 +44,7 @@ - active_class = ['registrar/invoices'].include?(params[:controller]) ? 'active' :nil %li{class: active_class}= link_to t(:billing), registrar_invoices_path - - if !Rails.env.production? && can?(:view, :registrar_xml_console) + - if !Rails.env.production? && can?(:manage, :xml_console) - active_class = ['registrar/xml_consoles'].include?(params[:controller]) ? 'active' :nil %li{class: active_class}= link_to t(:xml_console), registrar_xml_console_path diff --git a/app/views/registrar/dashboard/show.haml b/app/views/registrar/dashboard/show.haml new file mode 100644 index 000000000..74a9405a6 --- /dev/null +++ b/app/views/registrar/dashboard/show.haml @@ -0,0 +1,3 @@ +.panel.panel-default + .panel-body + = t('welcome_to_eis_registrar_portal') diff --git a/config/locales/en.yml b/config/locales/en.yml index 6b9151e5b..675226716 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -920,3 +920,4 @@ en: failure: "It was not saved" contact_is_not_valid: 'Contact %{value} is not valid, please fix the invalid contact' force_delete_subject: 'Kustutusmenetluse teade' + welcome_to_eis_registrar_portal: 'Welcome to EIS Registrar portal' diff --git a/config/routes.rb b/config/routes.rb index 24148befb..676cae912 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -19,7 +19,9 @@ Rails.application.routes.draw do # REGISTRAR ROUTES namespace :registrar do - root 'polls#show' + resource :dashboard + root 'dashboard#show' + # root 'polls#show' resources :invoices do member do From f7906800c4c9a7ac557d537750755ad4ba35b452 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Tue, 15 Sep 2015 12:11:12 +0300 Subject: [PATCH 21/41] Cleanup #2713 --- app/controllers/registrar/polls_controller.rb | 3 --- .../registrar/sessions_controller.rb | 7 ------ app/controllers/registrar_controller.rb | 13 ++--------- app/models/ability.rb | 23 ------------------- 4 files changed, 2 insertions(+), 44 deletions(-) diff --git a/app/controllers/registrar/polls_controller.rb b/app/controllers/registrar/polls_controller.rb index 76e574e95..e29f02f67 100644 --- a/app/controllers/registrar/polls_controller.rb +++ b/app/controllers/registrar/polls_controller.rb @@ -3,12 +3,10 @@ class Registrar::PollsController < Registrar::DeppController # EPP controller before_action :init_epp_xml def show - # authorize! :view, :registrar_dashboard @data = depp_current_user.request(@ex.poll) end def destroy - # authorize! :delete, :registrar_poll @data = depp_current_user.request(@ex.poll(poll: { value: '', attrs: { op: 'ack', msgID: params[:id] } })) @@ -35,7 +33,6 @@ class Registrar::PollsController < Registrar::DeppController # EPP controller # end def confirm_transfer - # authorize! :confirm, :transfer domain_params = params[:domain] @data = @domain.confirm_transfer(domain_params) diff --git a/app/controllers/registrar/sessions_controller.rb b/app/controllers/registrar/sessions_controller.rb index 198860f49..ff97c4f2c 100644 --- a/app/controllers/registrar/sessions_controller.rb +++ b/app/controllers/registrar/sessions_controller.rb @@ -70,13 +70,6 @@ class Registrar::SessionsController < Devise::SessionsController flash[:alert] = I18n.t(:ip_is_not_whitelisted) redirect_to :back and return end - - # if @api_user.can?(:create, :epp_login) - # unless @api_user.registrar.api_ip_white?(request.ip) - # flash[:alert] = I18n.t(:ip_is_not_whitelisted) - # redirect_to :back and return - # end - # end end sign_in @api_user if @api_user.identity_code == current_user.identity_code diff --git a/app/controllers/registrar_controller.rb b/app/controllers/registrar_controller.rb index f70b82849..47d596fd3 100644 --- a/app/controllers/registrar_controller.rb +++ b/app/controllers/registrar_controller.rb @@ -9,29 +9,20 @@ class RegistrarController < ApplicationController false end - # rubocop:disable Metrics/PerceivedComplexity - # rubocop:disable Metrics/CyclomaticComplexity def check_ip return unless current_user unless current_user.is_a? ApiUser sign_out(current_user) return end - # return if Rails.env.development? + return if Rails.env.development? registrar_ip_whitelisted = current_user.registrar.registrar_ip_white?(request.ip) - # api_ip_whitelisted = true - # if current_user.can?(:create, :epp_request) - # api_ip_whitelisted = current_user.registrar.api_ip_white?(request.ip) - # end - - return if registrar_ip_whitelisted # && api_ip_whitelisted + return if registrar_ip_whitelisted flash[:alert] = t('ip_is_not_whitelisted') sign_out(current_user) redirect_to registrar_login_path and return end - # rubocop:enable Metrics/PerceivedComplexity - # rubocop:enable Metrics/CyclomaticComplexity helper_method :head_title_sufix def head_title_sufix diff --git a/app/models/ability.rb b/app/models/ability.rb index bb120dc2f..cf98cb704 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -30,21 +30,16 @@ class Ability # def super # Registrar/api_user dynamic role - static_registrar epp billing end def epp # Registrar/api_user dynamic role - # static_registrar can :view, :registrar_dashboard if @user.registrar.api_ip_white?(@ip) can :manage, :poll can :manage, Depp::Contact - # can :manage, Depp::Domain - # can :renew, Depp::Domain - # can :transfer, Depp::Domain # can :manage, Depp::Keyrelay # TODO: Keyrelay is disabled for now # can :confirm, :keyrelay # TODO: Keyrelay is disabled for now can :manage, :xml_console @@ -84,7 +79,6 @@ class Ability can(:manage, Invoice) { |i| i.buyer_id == @user.registrar_id } can :manage, :deposit can :read, AccountActivity - #can(:create, :epp_login) # billing can establis epp connection in order to login end def customer_service # Admin/admin_user dynamic role @@ -122,23 +116,6 @@ class Ability can :access, :settings_menu end - # - # Static roles, linked from dynamic roles - # - def static_registrar - #can :manage, Nameserver - # can :view, :registrar_dashboard - # can :delete, :registrar_poll - # can :manage, :registrar_xml_console - # can :manage, Depp::Contact - # can :manage, Depp::Domain - # can :renew, Depp::Domain - # can :transfer, Depp::Domain - # can :manage, Depp::Keyrelay - # can :confirm, :keyrelay - # can :confirm, :transfer - end - def static_registrant can :manage, :registrant_domains can :manage, :registrant_whois From 0a73f77130bbaf733e022e7ea31df9f6f257aa74 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Tue, 15 Sep 2015 12:12:51 +0300 Subject: [PATCH 22/41] Cleanup #2713 --- app/controllers/registrar/dashboard_controller.rb | 6 ------ config/routes.rb | 1 - 2 files changed, 7 deletions(-) diff --git a/app/controllers/registrar/dashboard_controller.rb b/app/controllers/registrar/dashboard_controller.rb index a2364e973..cdbc70b0c 100644 --- a/app/controllers/registrar/dashboard_controller.rb +++ b/app/controllers/registrar/dashboard_controller.rb @@ -7,11 +7,5 @@ class Registrar::DashboardController < RegistrarController elsif can?(:show, Invoice) redirect_to registrar_invoices_url and return end - - # if current_user.try(:roles) == ['billing'] - # redirect_to registrar_invoices_url and return - # elsif can?(:show, :poll) - # redirect_to registrar_poll_url and return - # end end end diff --git a/config/routes.rb b/config/routes.rb index 676cae912..5431cdbf4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -21,7 +21,6 @@ Rails.application.routes.draw do namespace :registrar do resource :dashboard root 'dashboard#show' - # root 'polls#show' resources :invoices do member do From cc323123287e8b63fa7e2ec1f85e0c288344c93e Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Tue, 15 Sep 2015 12:22:31 +0300 Subject: [PATCH 23/41] Fix tests #2713 --- spec/features/registrar/account_activity_spec.rb | 2 +- spec/features/registrar/domain_spec.rb | 2 ++ spec/features/registrar/invoices_spec.rb | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/spec/features/registrar/account_activity_spec.rb b/spec/features/registrar/account_activity_spec.rb index a9cc9c59e..3d97be16a 100644 --- a/spec/features/registrar/account_activity_spec.rb +++ b/spec/features/registrar/account_activity_spec.rb @@ -20,7 +20,7 @@ feature 'Account activity', type: :feature do end it 'should navigate to account activities page' do - current_path.should == '/registrar' + current_path.should == '/registrar/poll' click_link 'Billing' click_link 'Account activity' diff --git a/spec/features/registrar/domain_spec.rb b/spec/features/registrar/domain_spec.rb index 3eecd5d10..956ddef4d 100644 --- a/spec/features/registrar/domain_spec.rb +++ b/spec/features/registrar/domain_spec.rb @@ -54,6 +54,8 @@ feature 'Domains', type: :feature do click_link "#{user2} (#{user2.roles.first}) - #{user2.registrar}" + visit '/registrar/domains' + page.should_not have_text(d1.name) page.should have_text(d2.name) end diff --git a/spec/features/registrar/invoices_spec.rb b/spec/features/registrar/invoices_spec.rb index 37e3737dd..fee6e8fb6 100644 --- a/spec/features/registrar/invoices_spec.rb +++ b/spec/features/registrar/invoices_spec.rb @@ -20,7 +20,7 @@ feature 'Invoices', type: :feature do end it 'should navigate to the domains index page' do - current_path.should == '/registrar' + current_path.should == '/registrar/poll' click_link 'Billing' current_path.should == '/registrar/invoices' @@ -58,6 +58,7 @@ feature 'Invoices', type: :feature do page.should have_text(@invoice.to_s) page.should have_text('Buyer') click_link "#{user2} (#{user2.roles.first}) - #{user2.registrar}" + visit "/registrar/invoices/#{@invoice.id}" page.should have_text('You are not authorized to access this page.') visit "/registrar/invoices/#{@invoice.id}/forward" From c6073c7e87f080b535edd5049776a4499423e380 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Tue, 15 Sep 2015 14:00:19 +0300 Subject: [PATCH 24/41] Restructure white ip interfaces #2713 --- app/controllers/admin/white_ips_controller.rb | 2 +- app/models/white_ip.rb | 16 +++++++--------- app/views/admin/registrars/show.haml | 6 +++--- app/views/admin/white_ips/_form.haml | 12 +++++++----- app/views/admin/white_ips/show.haml | 4 ++-- config/locales/en.yml | 1 + ...94707_add_multiple_interfaces_for_white_ip.rb | 6 ++++++ db/schema-read-only.rb | 4 ++-- db/structure.sql | 4 +++- 9 files changed, 32 insertions(+), 23 deletions(-) create mode 100644 db/migrate/20150915094707_add_multiple_interfaces_for_white_ip.rb diff --git a/app/controllers/admin/white_ips_controller.rb b/app/controllers/admin/white_ips_controller.rb index 7c0ecb184..059094614 100644 --- a/app/controllers/admin/white_ips_controller.rb +++ b/app/controllers/admin/white_ips_controller.rb @@ -51,6 +51,6 @@ class Admin::WhiteIpsController < AdminController end def white_ip_params - params.require(:white_ip).permit(:ipv4, :ipv6, :interface, :registrar_id) + params.require(:white_ip).permit(:ipv4, :ipv6, :registrar_id, { interfaces: [] }) end end diff --git a/app/models/white_ip.rb b/app/models/white_ip.rb index 7a35a33f6..918315004 100644 --- a/app/models/white_ip.rb +++ b/app/models/white_ip.rb @@ -17,19 +17,17 @@ class WhiteIp < ActiveRecord::Base REGISTRAR = 'registrar' INTERFACES = [API, REGISTRAR] - scope :api, -> { where(interface: API) } - scope :registrar, -> { where(interface: REGISTRAR) } + scope :api, -> { where("interfaces @> ?::varchar[]", "{#{API}}") } + scope :registrar, -> { where("interfaces @> ?::varchar[]", "{#{REGISTRAR}}") } + + def interfaces=(interfaces) + super(interfaces.reject(&:blank?)) + end class << self def registrar_ip_white?(ip) return true unless Setting.registrar_ip_whitelist_enabled - - at = WhiteIp.arel_table - WhiteIp.where( - at[:interface].eq(REGISTRAR).and( - at[:ipv4].eq(ip) - ) - ).any? + WhiteIp.where(ipv4: ip).registrar.any? end end end diff --git a/app/views/admin/registrars/show.haml b/app/views/admin/registrars/show.haml index d41a0f9fd..c44523d87 100644 --- a/app/views/admin/registrars/show.haml +++ b/app/views/admin/registrars/show.haml @@ -92,10 +92,10 @@ %tr %th{class: 'col-xs-4'}= t(:ipv4) %th{class: 'col-xs-6'}= t(:ipv6) - %th{class: 'col-xs-2'}= t(:interface) + %th{class: 'col-xs-2'}= t(:interfaces) %tbody - - @registrar.white_ips.order(:interface).each do |x| + - @registrar.white_ips.each do |x| %tr %td= link_to(x.ipv4, [:admin, @registrar, x]) %td= link_to(x.ipv6, [:admin, @registrar, x]) - %td= x.interface.upcase + %td= x.interfaces.join(', ').upcase diff --git a/app/views/admin/white_ips/_form.haml b/app/views/admin/white_ips/_form.haml index 253501e24..7a0371697 100644 --- a/app/views/admin/white_ips/_form.haml +++ b/app/views/admin/white_ips/_form.haml @@ -19,11 +19,13 @@ = f.label :ipv6 .col-md-7 = f.text_field(:ipv6, class: 'form-control', ipv6: true, autocomplete: 'off') - .form-group - .col-md-4.control-label - = f.label :interface - .col-md-7 - = f.select :interface, WhiteIp::INTERFACES.map {|x| [x.upcase, x]}, {}, class: 'form-control selectize' + - WhiteIp::INTERFACES.each do |x| + .form-group + .col-md-4.control-label + = f.label x + .col-md-7 + = f.check_box :interfaces, { multiple: true }, x, nil + = hidden_field_tag "white_ip[interfaces][]", nil %hr .row .col-md-8.text-right diff --git a/app/views/admin/white_ips/show.haml b/app/views/admin/white_ips/show.haml index da1da9616..0cfec654c 100644 --- a/app/views/admin/white_ips/show.haml +++ b/app/views/admin/white_ips/show.haml @@ -20,5 +20,5 @@ %dt= t(:ipv6) %dd= @white_ip.ipv6 - %dt= t(:interface) - %dd= @white_ip.interface.upcase + %dt= t(:interfaces) + %dd= @white_ip.interfaces.join(', ').upcase diff --git a/config/locales/en.yml b/config/locales/en.yml index 675226716..40e9ce62b 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -921,3 +921,4 @@ en: contact_is_not_valid: 'Contact %{value} is not valid, please fix the invalid contact' force_delete_subject: 'Kustutusmenetluse teade' welcome_to_eis_registrar_portal: 'Welcome to EIS Registrar portal' + interfaces: 'Interfaces' diff --git a/db/migrate/20150915094707_add_multiple_interfaces_for_white_ip.rb b/db/migrate/20150915094707_add_multiple_interfaces_for_white_ip.rb new file mode 100644 index 000000000..59840e474 --- /dev/null +++ b/db/migrate/20150915094707_add_multiple_interfaces_for_white_ip.rb @@ -0,0 +1,6 @@ +class AddMultipleInterfacesForWhiteIp < ActiveRecord::Migration + def change + change_column :white_ips, :interface, "varchar[] USING (string_to_array(interface, ','))" + rename_column :white_ips, :interface, :interfaces + end +end diff --git a/db/schema-read-only.rb b/db/schema-read-only.rb index f7de8c32d..1903fb52f 100644 --- a/db/schema-read-only.rb +++ b/db/schema-read-only.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150910113839) do +ActiveRecord::Schema.define(version: 20150915094707) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -1064,7 +1064,7 @@ ActiveRecord::Schema.define(version: 20150910113839) do t.integer "registrar_id" t.string "ipv4" t.string "ipv6" - t.string "interface" + t.string "interfaces", array: true t.datetime "created_at" t.datetime "updated_at" t.string "creator_str" diff --git a/db/structure.sql b/db/structure.sql index c517c6576..01c6e60cf 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -2717,7 +2717,7 @@ CREATE TABLE white_ips ( registrar_id integer, ipv4 character varying, ipv6 character varying, - interface character varying, + interfaces character varying[], created_at timestamp without time zone, updated_at timestamp without time zone, creator_str character varying, @@ -4934,3 +4934,5 @@ INSERT INTO schema_migrations (version) VALUES ('20150827151906'); INSERT INTO schema_migrations (version) VALUES ('20150910113839'); +INSERT INTO schema_migrations (version) VALUES ('20150915094707'); + From b5afff1c79458b78fabe0b1533b9db9a80a8fa01 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Tue, 15 Sep 2015 14:02:26 +0300 Subject: [PATCH 25/41] Fix tests #2713 --- db/schema-read-only.rb | 1 - db/structure.sql | 3 --- spec/fabricators/registrar_fabricator.rb | 2 +- spec/fabricators/white_ip_fabricator.rb | 4 ++-- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/db/schema-read-only.rb b/db/schema-read-only.rb index 1903fb52f..0a9fea6ec 100644 --- a/db/schema-read-only.rb +++ b/db/schema-read-only.rb @@ -201,7 +201,6 @@ ActiveRecord::Schema.define(version: 20150915094707) do t.integer "legacy_id" t.string "statuses", array: true t.hstore "status_notes" - t.integer "legacy_history_id" t.integer "copy_from_id" end diff --git a/db/structure.sql b/db/structure.sql index 01c6e60cf..d08361887 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -597,7 +597,6 @@ CREATE TABLE contacts ( legacy_id integer, statuses character varying[], status_notes hstore, - legacy_history_id integer, copy_from_id integer ); @@ -4930,8 +4929,6 @@ INSERT INTO schema_migrations (version) VALUES ('20150810114746'); INSERT INTO schema_migrations (version) VALUES ('20150825125118'); -INSERT INTO schema_migrations (version) VALUES ('20150827151906'); - INSERT INTO schema_migrations (version) VALUES ('20150910113839'); INSERT INTO schema_migrations (version) VALUES ('20150915094707'); diff --git a/spec/fabricators/registrar_fabricator.rb b/spec/fabricators/registrar_fabricator.rb index c1f082083..bd801f642 100644 --- a/spec/fabricators/registrar_fabricator.rb +++ b/spec/fabricators/registrar_fabricator.rb @@ -9,7 +9,7 @@ Fabricator(:registrar) do country_code 'EE' code { sequence(:code) { |i| "REGISTRAR#{i}" } } reference_no { sequence(:reference_no) { |i| "RF#{i}" } } - white_ips { [Fabricate(:white_ip), Fabricate(:white_ip, interface: WhiteIp::REGISTRAR)] } + white_ips { [Fabricate(:white_ip), Fabricate(:white_ip, interfaces: [WhiteIp::REGISTRAR])] } end Fabricator(:registrar_with_no_account_activities, from: :registrar) do diff --git a/spec/fabricators/white_ip_fabricator.rb b/spec/fabricators/white_ip_fabricator.rb index 151cc6725..6eb574893 100644 --- a/spec/fabricators/white_ip_fabricator.rb +++ b/spec/fabricators/white_ip_fabricator.rb @@ -1,8 +1,8 @@ Fabricator(:white_ip) do ipv4 '127.0.0.1' - interface WhiteIp::API + interfaces [WhiteIp::API] end Fabricator(:white_ip_registrar, from: :white_ip) do - interface WhiteIp::REGISTRAR + interfaces [WhiteIp::REGISTRAR] end From e638b0db05ad2a63daaeee4017f76afddcd0369a Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Tue, 15 Sep 2015 14:55:54 +0300 Subject: [PATCH 26/41] Fix tests #2713 --- spec/features/admin/white_ip_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/admin/white_ip_spec.rb b/spec/features/admin/white_ip_spec.rb index 261ea134d..d077e687f 100644 --- a/spec/features/admin/white_ip_spec.rb +++ b/spec/features/admin/white_ip_spec.rb @@ -26,7 +26,7 @@ feature 'Api users', type: :feature do fill_in 'IPv4', with: '192.168.1.1' fill_in 'IPv6', with: 'FE80:0000:0000:0000:0202:B3FF:FE1E:8329' - select 'API', from: 'Interface' + find('#white_ip_interfaces_api').set(true) click_button 'Save' page.should have_text('Record created') From 6ff10268f34f274fcc4eb8105098efabf898e981 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Thu, 17 Sep 2015 15:53:06 +0300 Subject: [PATCH 27/41] Add method to reload settings #2925 --- Gemfile | 1 + app/models/setting.rb | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/Gemfile b/Gemfile index 8bf19fd3b..b52a299cd 100644 --- a/Gemfile +++ b/Gemfile @@ -25,6 +25,7 @@ gem 'validates_email_format_of', '1.6.3' # validates email against RFC 2822 and gem 'paper_trail', github: 'airblade/paper_trail', ref: 'a453811226ec4ea59753ba6b827e390ced2fc140' +# NB! if this gets upgraded, ensure Setting.reload_settings! still works correctly gem 'rails-settings-cached', '0.4.1' # for settings # html-xml diff --git a/app/models/setting.rb b/app/models/setting.rb index 005cce626..4a66df3a9 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -1,3 +1,7 @@ class Setting < RailsSettings::CachedSettings include Versions # version/setting_version.rb + + def self.reload_settings! + Rails.cache.delete_matched('settings:.*') + end end From 379545424c9e4154ba4f5e2307d8c927c46b3305 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Thu, 17 Sep 2015 16:17:42 +0300 Subject: [PATCH 28/41] Schedule test #2925 --- config/schedule.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config/schedule.rb b/config/schedule.rb index 265306904..8b1e1f041 100644 --- a/config/schedule.rb +++ b/config/schedule.rb @@ -9,6 +9,8 @@ path = Whenever.path.sub(%r{\/releases\/.*}, '/current') set :job_template, "/bin/bash -l -c '#{rbenv} :job'" job_type :runner, "cd #{path} && bin/rails r -e :environment \":task\" :output" +puts @environment + # cron output set :output, 'log/cron.log' @@ -52,3 +54,7 @@ end every 52.minutes do runner 'Domain.start_redemption_grace_period' end + +every 10.minutes do + runner 'Setting.reload_settings!' +end From 2a81641130ae4798c63ab82555069ca5aea08b35 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Thu, 17 Sep 2015 17:01:07 +0300 Subject: [PATCH 29/41] Whenever test #2925 --- config/schedule.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/config/schedule.rb b/config/schedule.rb index 8b1e1f041..b58625952 100644 --- a/config/schedule.rb +++ b/config/schedule.rb @@ -9,11 +9,14 @@ path = Whenever.path.sub(%r{\/releases\/.*}, '/current') set :job_template, "/bin/bash -l -c '#{rbenv} :job'" job_type :runner, "cd #{path} && bin/rails r -e :environment \":task\" :output" -puts @environment - # cron output set :output, 'log/cron.log' +puts 'domain' +puts @domain +puts 'env' +puts @environment + every 10.minutes do runner 'ZonefileSetting.generate_zonefiles' end From 89b6edf0df2ae821a0e526a2ac613838fa6e7472 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Thu, 17 Sep 2015 17:46:57 +0300 Subject: [PATCH 30/41] Update schedule #2925 --- config/schedule.rb | 66 ++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/config/schedule.rb b/config/schedule.rb index b58625952..a05534864 100644 --- a/config/schedule.rb +++ b/config/schedule.rb @@ -12,50 +12,52 @@ job_type :runner, "cd #{path} && bin/rails r -e :environment \":task\" :output" # cron output set :output, 'log/cron.log' -puts 'domain' -puts @domain +puts 'cron_group' +puts @cron_group puts 'env' puts @environment -every 10.minutes do - runner 'ZonefileSetting.generate_zonefiles' -end +if @cron_group == 'registry' + every 10.minutes do + runner 'ZonefileSetting.generate_zonefiles' + end -every 6.months, at: '12:01am' do - runner 'Contact.destroy_orphans' -end + every 6.months, at: '12:01am' do + runner 'Contact.destroy_orphans' + end -every :day, at: '12:10am' do - runner 'Invoice.cancel_overdue_invoices' -end + every :day, at: '12:10am' do + runner 'Invoice.cancel_overdue_invoices' + end -# TODO -# every :day, at: '12:15am' do - # runner 'Domain.expire_domains' -# end + # TODO + # every :day, at: '12:15am' do + # runner 'Domain.expire_domains' + # end -every :day, at: '12:20am' do - runner 'Domain.clean_expired_pendings' -end + every :day, at: '12:20am' do + runner 'Domain.clean_expired_pendings' + end -every 3.hours do - runner 'Certificate.update_crl' -end + every 3.hours do + runner 'Certificate.update_crl' + end -every 42.minutes do - runner 'Domain.destroy_delete_candidates' -end + every 42.minutes do + runner 'Domain.destroy_delete_candidates' + end -every 45.minutes do - runner 'Domain.start_expire_period' -end + every 45.minutes do + runner 'Domain.start_expire_period' + end -every 50.minutes do - runner 'Domain.start_delete_period' -end + every 50.minutes do + runner 'Domain.start_delete_period' + end -every 52.minutes do - runner 'Domain.start_redemption_grace_period' + every 52.minutes do + runner 'Domain.start_redemption_grace_period' + end end every 10.minutes do From fd5217250084ec3a2f465f4f41089aa9f17741dd Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Thu, 17 Sep 2015 17:52:47 +0300 Subject: [PATCH 31/41] Ident type update #2834 --- app/models/contact.rb | 13 +++++++------ app/models/depp/contact.rb | 4 ++-- app/models/epp/domain.rb | 4 ++-- db/schema-read-only.rb | 5 +++-- db/structure.sql | 9 +++++++-- lib/tasks/import.rake | 2 +- spec/epp/domain_spec.rb | 2 +- spec/features/registrar/contact_spec.rb | 4 ++-- spec/models/contact_spec.rb | 14 +++++++------- 9 files changed, 32 insertions(+), 25 deletions(-) diff --git a/app/models/contact.rb b/app/models/contact.rb index a995e2f03..a9dfe8cbb 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -23,7 +23,7 @@ class Contact < ActiveRecord::Base validates :ident, format: { with: /\d{4}-\d{2}-\d{2}/, message: :invalid_birthday_format }, if: proc { |c| c.ident_type == 'birthday' } - validates :ident_country_code, presence: true, if: proc { |c| %w(bic priv).include? c.ident_type } + validates :ident_country_code, presence: true, if: proc { |c| %w(org priv).include? c.ident_type } validates :code, uniqueness: { message: :epp_id_taken }, format: { with: /\A[\w\-\:]*\Z/i, message: :invalid }, @@ -64,13 +64,13 @@ class Contact < ActiveRecord::Base scope :current_registrars, ->(id) { where(registrar_id: id) } - BIC = 'bic' + ORG = 'org' PRIV = 'priv' BIRTHDAY = 'birthday' PASSPORT = 'passport' IDENT_TYPES = [ - BIC, # Company registry code (or similar) + ORG, # Company registry code (or similar) PRIV, # National idendtification number BIRTHDAY # Birthday date ] @@ -226,12 +226,13 @@ class Contact < ActiveRecord::Base false end - def bic? - ident_type == BIC + def org? + ident_type == ORG end + # it might mean priv or birthday type def priv? - ident_type != BIC + !org? end def generate_auth_info diff --git a/app/models/depp/contact.rb b/app/models/depp/contact.rb index 316d78818..a1f781971 100644 --- a/app/models/depp/contact.rb +++ b/app/models/depp/contact.rb @@ -267,8 +267,8 @@ module Depp Country.new(country_code) end - def bic? - ident_type == 'bic' + def org? + ident_type == 'org' end def priv? diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 34d0e01e3..c8ceef2dc 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -137,7 +137,7 @@ class Epp::Domain < Domain return if registrant.blank? regt = Registrant.find(registrant.id) # temp for bullet tech_contacts << regt if tech_domain_contacts.blank? - admin_contacts << regt if admin_domain_contacts.blank? && regt.priv? + admin_contacts << regt if admin_domain_contacts.blank? && !regt.org? end # rubocop: disable Metrics/PerceivedComplexity @@ -283,7 +283,7 @@ class Epp::Domain < Domain end if action != 'rem' - if x['type'] == 'admin' && c.bic? + if x['type'] == 'admin' && c.org? add_epp_error('2306', 'contact', x.text, [:domain_contacts, :admin_contact_can_be_only_private_person]) next end diff --git a/db/schema-read-only.rb b/db/schema-read-only.rb index 0a9fea6ec..615e64008 100644 --- a/db/schema-read-only.rb +++ b/db/schema-read-only.rb @@ -201,6 +201,7 @@ ActiveRecord::Schema.define(version: 20150915094707) do t.integer "legacy_id" t.string "statuses", array: true t.hstore "status_notes" + t.integer "legacy_history_id" t.integer "copy_from_id" end @@ -887,8 +888,8 @@ ActiveRecord::Schema.define(version: 20150915094707) do t.string "cc" t.text "body", null: false t.text "text_body", null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" end create_table "messages", force: :cascade do |t| diff --git a/db/structure.sql b/db/structure.sql index d08361887..75246ec42 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -597,6 +597,7 @@ CREATE TABLE contacts ( legacy_id integer, statuses character varying[], status_notes hstore, + legacy_history_id integer, copy_from_id integer ); @@ -2242,8 +2243,8 @@ CREATE TABLE mail_templates ( cc character varying, body text NOT NULL, text_body text NOT NULL, - created_at timestamp without time zone NOT NULL, - updated_at timestamp without time zone NOT NULL + created_at timestamp without time zone, + updated_at timestamp without time zone ); @@ -4927,8 +4928,12 @@ INSERT INTO schema_migrations (version) VALUES ('20150803080914'); INSERT INTO schema_migrations (version) VALUES ('20150810114746'); +INSERT INTO schema_migrations (version) VALUES ('20150810114747'); + INSERT INTO schema_migrations (version) VALUES ('20150825125118'); +INSERT INTO schema_migrations (version) VALUES ('20150827151906'); + INSERT INTO schema_migrations (version) VALUES ('20150910113839'); INSERT INTO schema_migrations (version) VALUES ('20150915094707'); diff --git a/lib/tasks/import.rake b/lib/tasks/import.rake index 7b3625ad2..54f85b105 100644 --- a/lib/tasks/import.rake +++ b/lib/tasks/import.rake @@ -138,7 +138,7 @@ namespace :import do ident_type_map = { 2 => Contact::PRIV, 3 => Contact::PASSPORT, - 4 => Contact::BIC, + 4 => Contact::ORG, 6 => Contact::BIRTHDAY } diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index a3efb30da..473ea3cf3 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -23,7 +23,7 @@ describe 'EPP Domain', epp: true do Fabricate(:contact, code: 'FIXED:CITIZEN_1234') Fabricate(:contact, code: 'FIXED:SH8013') Fabricate(:contact, code: 'FIXED:SH801333') - Fabricate(:contact, code: 'FIXED:JURIDICAL_1234', ident_type: 'bic') + Fabricate(:contact, code: 'FIXED:JURIDICAL_1234', ident_type: 'org') Fabricate(:reserved_domain) Fabricate(:blocked_domain) @pricelist_reg_1_year = Fabricate(:pricelist, valid_to: nil) diff --git a/spec/features/registrar/contact_spec.rb b/spec/features/registrar/contact_spec.rb index bf0ebcda4..6e3b1dfba 100644 --- a/spec/features/registrar/contact_spec.rb +++ b/spec/features/registrar/contact_spec.rb @@ -62,7 +62,7 @@ feature 'Contact', type: :feature do visit '/registrar/contacts/new' current_path.should == '/registrar/contacts/new' - fill_in 'depp_contact_ident', with: 'bic-ident' + fill_in 'depp_contact_ident', with: 'org-ident' fill_in 'depp_contact_name', with: 'Business Name Ltd' fill_in 'depp_contact_email', with: 'example@example.com' fill_in 'depp_contact_street', with: 'Example street 12' @@ -72,7 +72,7 @@ feature 'Contact', type: :feature do click_button 'Create' page.should have_text('Business Name Ltd') - page.should have_text('bic-ident [EE bic]') + page.should have_text('org-ident [EE org]') end it 'should create new contact with success' do diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb index 4407fdac2..79d96030b 100644 --- a/spec/models/contact_spec.rb +++ b/spec/models/contact_spec.rb @@ -53,8 +53,8 @@ describe Contact do @contact.errors[:phone].should == ["Phone nr is invalid"] end - it 'should require country code when bic' do - @contact.ident_type = 'bic' + it 'should require country code when org' do + @contact.ident_type = 'org' @contact.valid? @contact.errors[:ident_country_code].should == ['is missing'] end @@ -66,7 +66,7 @@ describe Contact do end it 'should validate correct country code' do - @contact.ident_type = 'bic' + @contact.ident_type = 'org' @contact.ident_country_code = 'EE' @contact.valid? @@ -75,7 +75,7 @@ describe Contact do it 'should require valid country code' do @contact.ident = '123' - @contact.ident_type = 'bic' + @contact.ident_type = 'org' @contact.ident_country_code = 'INVALID' @contact.valid? @@ -84,7 +84,7 @@ describe Contact do end it 'should convert to alpha2 country code' do - @contact.ident_type = 'bic' + @contact.ident_type = 'org' @contact.ident_country_code = 'ee' @contact.valid? @@ -148,8 +148,8 @@ describe Contact do @contact.domains_present?.should == false end - it 'bic should be valid' do - @contact.ident_type = 'bic' + it 'org should be valid' do + @contact.ident_type = 'org' @contact.ident = '1234' @contact.valid? @contact.errors.full_messages.should match_array([]) From 9c825ac9503aff4d89e43240724478777e8efc06 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Thu, 17 Sep 2015 18:06:51 +0300 Subject: [PATCH 32/41] Update schedule #2925 --- config/schedule.rb | 5 ----- 1 file changed, 5 deletions(-) diff --git a/config/schedule.rb b/config/schedule.rb index a05534864..5524f10ab 100644 --- a/config/schedule.rb +++ b/config/schedule.rb @@ -12,11 +12,6 @@ job_type :runner, "cd #{path} && bin/rails r -e :environment \":task\" :output" # cron output set :output, 'log/cron.log' -puts 'cron_group' -puts @cron_group -puts 'env' -puts @environment - if @cron_group == 'registry' every 10.minutes do runner 'ZonefileSetting.generate_zonefiles' From bd31b1388a6de5481310ca3a2b3aa507cc44d0a0 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Thu, 17 Sep 2015 18:13:24 +0300 Subject: [PATCH 33/41] Update deploy-example #2925 --- config/deploy-example.rb | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/config/deploy-example.rb b/config/deploy-example.rb index 7454fe0a7..655838070 100644 --- a/config/deploy-example.rb +++ b/config/deploy-example.rb @@ -17,6 +17,7 @@ set :repository, 'https://github.com/domify/registry' # dev repo set :branch, 'master' set :rails_env, 'alpha' set :que_restart, true +set :cron_group, 'registry' # alpha branch, only use for heavy debugging task :epp do @@ -36,6 +37,7 @@ task :registrar do set :branch, 'master' set :rails_env, 'alpha' set :que_restart, false + set :cron_group, 'registrar' end # alpha branch, only use for heavy debugging @@ -46,6 +48,7 @@ task :registrant do set :branch, 'master' set :rails_env, 'alpha' set :que_restart, false + set :cron_group, 'registrant' end # staging @@ -66,6 +69,7 @@ task :eppst do set :branch, 'staging' set :rails_env, 'staging' set :que_restart, false + set :cron_group, 'epp' end # staging @@ -76,6 +80,7 @@ task :registrarst do set :branch, 'staging' set :rails_env, 'staging' set :que_restart, false + set :cron_group, 'registrar' end # staging @@ -86,6 +91,7 @@ task :registrantst do set :branch, 'staging' set :rails_env, 'staging' set :que_restart, false + set :cron_group, 'registrant' end # production @@ -106,6 +112,7 @@ task :epppr do set :branch, 'master' set :rails_env, 'production' set :que_restart, false + set :cron_group, 'epp' end # production @@ -116,6 +123,7 @@ task :registrarpr do set :branch, 'master' set :rails_env, 'production' set :que_restart, false + set :cron_group, 'registrar' end # production @@ -126,6 +134,7 @@ task :registrantpr do set :branch, 'master' set :rails_env, 'production' set :que_restart, false + set :cron_group, 'registrant' end # Manually create these paths in shared/ (eg: shared/config/database.yml) in your server. @@ -234,7 +243,7 @@ end desc 'Restart que server' task que_restart: :environment do - queue "/etc/init.d/que restart" + queue "/etc/init.d/que restart" end namespace :cron do @@ -251,6 +260,32 @@ namespace :cron do end end +namespace :whenever do + name = -> { "#{domain}_#{rails_env}" } + + desc "Clear crontab" + task clear: :environment do + queue %( + echo "-----> Clear crontab for #{name.call}" + #{echo_cmd %(cd #{deploy_to!}/#{current_path!} ; #{bundle_bin} exec whenever --clear-crontab #{name.call} --set 'environment=#{rails_env}&path=#{deploy_to!}/#{current_path!}&cron_group=#{cron_group}')} + ) + end + desc "Update crontab" + task update: :environment do + queue %( + echo "-----> Update crontab for #{name.call}" + #{echo_cmd %(cd #{deploy_to!}/#{current_path!} ; #{bundle_bin} exec whenever --update-crontab #{name.call} --set 'environment=#{rails_env}&path=#{deploy_to!}/#{current_path!}&cron_group=#{cron_group}')} + ) + end + desc "Write crontab" + task write: :environment do + queue %( + echo "-----> Update crontab for #{name.call}" + #{echo_cmd %(cd #{deploy_to!}/#{current_path!} ; #{bundle_bin} exec whenever --write-crontab #{name.call} --set 'environment=#{rails_env}&path=#{deploy_to!}/#{current_path!}&cron_group=#{cron_group}')} + ) + end +end + # For help in making your deploy script, see the Mina documentation: # # - http://nadarei.co/mina From 55b569031bfebe55d933c94f934e6f9e59541834 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Thu, 17 Sep 2015 18:17:03 +0300 Subject: [PATCH 34/41] Improve readme #2925 --- CHANGELOG.md | 3 +++ doc/application_build_doc.md | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d77d6b6a9..889aff165 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +17.09.2015 +* deploy-example.rb has been updated with `@cron_group`. + 11.08.2015 * Possible to add whitelist_emails_for_staging list at application.yml diff --git a/doc/application_build_doc.md b/doc/application_build_doc.md index 4dc9535b4..dcc0190b7 100644 --- a/doc/application_build_doc.md +++ b/doc/application_build_doc.md @@ -117,7 +117,7 @@ General rake and mina tips: ### CRON -Crontab can be setup after deploy. Jobs can be viewed [here](/config/schedule.rb). +Crontab can be setup after deploy. Jobs can be viewed [here](/config/schedule.rb). Some jobs are dependent on `cron_group` variable set in [deploy-example.rb](/config/deploy-example.rb) file. mina pr cron:setup # to update the crontab. mina pr cron:clear # to clear crontab. From 3f9b3e991aa319f2fed8e3c47b41f6bf329de81a Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Thu, 17 Sep 2015 18:18:38 +0300 Subject: [PATCH 35/41] Update deploy example #2925 --- config/deploy-example.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/config/deploy-example.rb b/config/deploy-example.rb index 655838070..f6cd5dee6 100644 --- a/config/deploy-example.rb +++ b/config/deploy-example.rb @@ -1,7 +1,6 @@ require 'mina/bundler' require 'mina/rails' require 'mina/git' -require 'mina/whenever' require 'mina/rbenv' # for rbenv support. (http://rbenv.org) # Basic settings: From 1fbc5ec6ee6827ddfb3fc5c183fe70040a1aa862 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Thu, 17 Sep 2015 18:32:39 +0300 Subject: [PATCH 36/41] Add loggin to cache clear cron #2925 --- app/models/setting.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/setting.rb b/app/models/setting.rb index 4a66df3a9..122bfc99a 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -2,6 +2,8 @@ class Setting < RailsSettings::CachedSettings include Versions # version/setting_version.rb def self.reload_settings! + STDOUT << "#{Time.zone.now.utc} - Clearing settings cache\n" Rails.cache.delete_matched('settings:.*') + STDOUT << "#{Time.zone.now.utc} - Settings cache cleared\n" end end From 2c3d8ac7d429c754936ad63bc985bede1d3bee52 Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Sun, 20 Sep 2015 14:11:32 +0300 Subject: [PATCH 37/41] Translation update --- config/locales/en.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 40e9ce62b..a7af25dcf 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -277,7 +277,7 @@ en: name: 'Name' transfer_can_be_approved_only_by_current_registrar: 'Transfer can be approved only by current domain registrar' registrar: 'Registrar' - owner: 'Owner' + owner: 'Registrant' domain_details: 'Domain details' registered_at: 'Registered at' password: 'Password' @@ -804,20 +804,20 @@ en: edit_white_ip: 'Edit white IP' confirm_domain_delete: 'Confirm domain delete' reject_domain_delete: 'Reject domain delete' - confirm_domain_registrant_update: 'Confirm domain ownership change' - reject_domain_registrant_update: 'Reject domain ownership change' - domain_registrant_change_title: 'Please confirm or reject domain ownership change' - domain_registrant_change_body: 'There is a request to change domain ownership. Before doing it we need your confirmation.' + confirm_domain_registrant_update: 'Confirm domain registrant change' + reject_domain_registrant_update: 'Reject domain registrant change' + domain_registrant_change_title: 'Please confirm or reject domain registrant change' + domain_registrant_change_body: 'There is a request to change domain registrant. Before doing it we need your confirmation.' new_pending_registrant: 'New registrant' current_registrant: 'Current registrant' registrant_domain_verification_failed: 'Domain verification not available' - domain_registrant_change_confirmed_title: 'Domain owner change has been received' - domain_registrant_change_confirmed_body: 'You have successfully submitted domain owner change confirmation. You will receive email confirmation.' - registrant_domain_verification_confirmed: 'Domain owner change has successfully received.' + domain_registrant_change_confirmed_title: 'Domain registrant change has been received' + domain_registrant_change_confirmed_body: 'You have successfully submitted domain registrant change confirmation. You will receive email confirmation.' + registrant_domain_verification_confirmed: 'Domain registrant change has successfully received.' registrant_domain_verification_confirmed_failed: 'Something went wrong.' - domain_registrant_change_rejected_title: 'Domain owner change has been rejected' - domain_registrant_change_rejected_body: 'You have rejected domain owner change.' - registrant_domain_verification_rejected: 'Domain owner change has been rejected successfully.' + domain_registrant_change_rejected_title: 'Domain registrant change has been rejected' + domain_registrant_change_rejected_body: 'You have rejected domain registrant change.' + registrant_domain_verification_rejected: 'Domain registrant change has been rejected successfully.' registrant_domain_verification_rejected_failed: 'Something went wrong.' domain_delete_title: 'Please confirm or reject domain deletation' domain_delete_body: 'There is a request to delete a domain. Before doing it we need your confirmation.' From 0944bd2077f4a96aeb13792b49b9523f88e8b1ad Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Tue, 22 Sep 2015 14:20:42 +0300 Subject: [PATCH 38/41] Improve YAML validation on reserved domain list #2962 --- app/controllers/admin/reserved_domains_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/admin/reserved_domains_controller.rb b/app/controllers/admin/reserved_domains_controller.rb index eb3a5faae..b83500083 100644 --- a/app/controllers/admin/reserved_domains_controller.rb +++ b/app/controllers/admin/reserved_domains_controller.rb @@ -11,6 +11,7 @@ class Admin::ReservedDomainsController < AdminController begin names = YAML.load(params[:reserved_domains]) + fail if names == false rescue flash.now[:alert] = I18n.t('invalid_yaml') logger.warn 'Invalid YAML' From 4a32c7641ce3b76abd889cb669560a6af7522120 Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Wed, 23 Sep 2015 12:32:26 +0300 Subject: [PATCH 39/41] Allow invalid ident update #2859 --- CHANGELOG.md | 3 +++ app/controllers/epp/contacts_controller.rb | 3 --- app/models/contact.rb | 1 + app/models/depp/contact.rb | 24 +++++++++++++------ app/models/epp/contact.rb | 15 ++++++++++++ .../contacts/form_partials/_general.haml | 21 +++++++++------- .../registrar/contacts/partials/_general.haml | 1 - .../contacts/partials/_statuses.haml | 2 -- config/locales/en.yml | 3 +-- .../20150903105659_add_updated_token.rb | 5 ++++ .../20150921110152_update_contacts_logs.rb | 5 ++++ ...0921111842_rename_contact_ident_updator.rb | 6 +++++ db/schema-read-only.rb | 10 ++++---- db/structure.sql | 12 ++++++++-- doc/schemas/eis-1.0.xsd | 2 +- lib/schemas/eis-1.0.xsd | 2 +- lib/sorted_country.rb | 2 +- spec/models/contact_spec.rb | 16 +++++++++++++ 18 files changed, 101 insertions(+), 32 deletions(-) create mode 100644 db/migrate/20150903105659_add_updated_token.rb create mode 100644 db/migrate/20150921110152_update_contacts_logs.rb create mode 100644 db/migrate/20150921111842_rename_contact_ident_updator.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 889aff165..68391b057 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +21.09.2015 +* eis-1.0.xsd schema file updated without a new version, please publish a new updated schema file to public. + 17.09.2015 * deploy-example.rb has been updated with `@cron_group`. diff --git a/app/controllers/epp/contacts_controller.rb b/app/controllers/epp/contacts_controller.rb index 2ee87d24c..5b0a39bbf 100644 --- a/app/controllers/epp/contacts_controller.rb +++ b/app/controllers/epp/contacts_controller.rb @@ -126,9 +126,6 @@ class Epp::ContactsController < EppController contact_org_disabled fax_disabled status_editing_disabled - if params[:parsed_frame].css('ident').present? - epp_errors << { code: '2306', msg: "#{I18n.t(:ident_update_error)} [ident]" } - end requires 'id' @prefix = nil end diff --git a/app/models/contact.rb b/app/models/contact.rb index a9dfe8cbb..b6be9f76d 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -34,6 +34,7 @@ class Contact < ActiveRecord::Base after_initialize do self.statuses = [] if statuses.nil? self.status_notes = {} if status_notes.nil? + self.ident_updated_at = Time.zone.now if new_record? && ident_updated_at.blank? end before_validation :set_ident_country_code diff --git a/app/models/depp/contact.rb b/app/models/depp/contact.rb index a1f781971..d85292bad 100644 --- a/app/models/depp/contact.rb +++ b/app/models/depp/contact.rb @@ -10,9 +10,9 @@ module Depp DISABLED = 'Disabled' DISCLOSURE_TYPES = [DISABLED, '1', '0'] - TYPES = %w( bic priv birthday ) + TYPES = %w( org priv birthday ) SELECTION_TYPES = [ - ['Business code', 'bic'], + ['Business code', 'org'], ['Personal identification code', 'priv'], ['Birthday', 'birthday'] ] @@ -163,7 +163,7 @@ module Depp } hash[:id] = nil if code.blank? - create_xml = Depp::Contact.epp_xml.create(hash, extension_xml) + create_xml = Depp::Contact.epp_xml.create(hash, extension_xml(:create)) data = Depp::Contact.user.request(create_xml) self.id = data.css('id').text @@ -210,7 +210,7 @@ module Depp } } }, - extension_xml + extension_xml(:update) ) data = Depp::Contact.user.request(update_xml) handle_errors(data) @@ -224,15 +224,25 @@ module Depp id: { value: id }, authInfo: { pw: { value: password } } }, - extension_xml + extension_xml(:delete) ) data = Depp::Contact.user.request(delete_xml) handle_errors(data) end - def extension_xml + def extension_xml(action) xml = { _anonymus: [] } - ident = ident_xml[:_anonymus].try(:first) unless persisted? + + case action + when :create + ident = ident_xml[:_anonymus].try(:first) + when :update + # detect if any ident has changed + if !(ident == self.ident && ident == self.ident_type && ident_country_code == self.ident_country_code) + ident = ident_xml[:_anonymus].try(:first) + end + end + legal = legal_document_xml[:_anonymus].try(:first) xml[:_anonymus] << ident if ident.present? xml[:_anonymus] << legal if legal.present? diff --git a/app/models/epp/contact.rb b/app/models/epp/contact.rb index 3136beabd..8054d590b 100644 --- a/app/models/epp/contact.rb +++ b/app/models/epp/contact.rb @@ -118,6 +118,7 @@ class Epp::Contact < Contact [:ident, :invalid_EE_identity_format], [:ident, :invalid_birthday_format], [:ident, :invalid_country_code], + [:ident_type, :missing], [:code, :invalid], [:code, :too_long_contact_code] ], @@ -144,6 +145,20 @@ class Epp::Contact < Contact legal_frame = frame.css('legalDocument').first at[:legal_documents_attributes] = self.class.legal_document_attrs(legal_frame) self.deliver_emails = true # turn on email delivery for epp + + # allow to update ident code for legacy contacts + if frame.css('ident').first.present? + if ident_updated_at.present? + throw :epp_error, { + code: '2306', + msg: I18n.t(:ident_update_error) + } + else + at.merge!(self.class.ident_attrs(frame.css('ident').first)) + self.ident_updated_at = Time.zone.now + end + end + super(at) end diff --git a/app/views/registrar/contacts/form_partials/_general.haml b/app/views/registrar/contacts/form_partials/_general.haml index b5f9eb0f9..a6ecbb500 100644 --- a/app/views/registrar/contacts/form_partials/_general.haml +++ b/app/views/registrar/contacts/form_partials/_general.haml @@ -1,3 +1,11 @@ +- ident_complete = f.object.ident_country_code.present? && f.object.ident_type.present? && f.object.ident.present? +- if @contact.persisted? + - country_selected = f.object.ident_country_code || (params[:depp_contact].try(:[], :ident_country_code)) + - type_selected = f.object.ident_type || (params[:depp_contact].try(:[], :ident_type)) +- else + - country_selected = (params[:depp_contact].try(:[], :ident_country_code) || 'EE') + - type_selected = (params[:depp_contact].try(:[], :ident_type) || 'org') + .panel.panel-default .panel-heading.clearfix .pull-left= t(:ident) @@ -6,12 +14,11 @@ .col-md-3.control-label = f.label :ident_country_code, t(:country) + '*' .col-md-7 - - if @contact.persisted? && f.object.ident_country_code.present? + - if ident_complete && @contact.persisted? && f.object.ident_country_code.present? .disabled-value = Country.new(f.object.ident_country_code).try(:to_s) = " [#{f.object.ident_country_code}]" - else - - country_selected = @contact.persisted? ? '' : (params[:depp_contact].try(:[], :ident_country_code) || 'EE') = f.select(:ident_country_code, SortedCountry.all_options(country_selected), {}, class: 'js-ident-country-code', required: true) @@ -19,25 +26,23 @@ .col-md-3.control-label = f.label :ident_type, t(:type) + '*' .col-md-7 - - if @contact.persisted? && f.object.ident_type.present? + - if ident_complete && @contact.persisted? && f.object.ident_type.present? .disabled-value = Depp::Contact.type_string(f.object.ident_type) = " [#{f.object.ident_type}]" - else - - type_selected = @contact.persisted? ? '' : (params[:depp_contact].try(:[], :ident_type) || 'bic') - = f.select(:ident_type, Depp::Contact::SELECTION_TYPES, - { selected: type_selected }, + = f.select(:ident_type, Depp::Contact::SELECTION_TYPES, { selected: type_selected }, class: 'js-ident-type', required: true) .form-group .col-md-3.control-label = f.label :ident, t(:ident) + '*' .col-md-7 - - if @contact.persisted? && f.object.ident.present? + - if ident_complete && @contact.persisted? && f.object.ident.present? .disabled-value = f.object.ident - else - = f.text_field :ident, class: 'form-control', required: true, disabled: @contact.persisted? + = f.text_field :ident, class: 'form-control', required: true - tip_visibility = f.object.ident_type == 'birthday' ? '' : 'display: none' .js-ident-tip{ style: tip_visibility } = t(:birthday_format) diff --git a/app/views/registrar/contacts/partials/_general.haml b/app/views/registrar/contacts/partials/_general.haml index b0728120c..37bd87555 100644 --- a/app/views/registrar/contacts/partials/_general.haml +++ b/app/views/registrar/contacts/partials/_general.haml @@ -10,7 +10,6 @@ %dd = text_field_tag :password, @contact.password, readonly: true, class: 'partially-hidden' - %br %dt= t(:ident) diff --git a/app/views/registrar/contacts/partials/_statuses.haml b/app/views/registrar/contacts/partials/_statuses.haml index 5d41db972..c926c04cf 100644 --- a/app/views/registrar/contacts/partials/_statuses.haml +++ b/app/views/registrar/contacts/partials/_statuses.haml @@ -12,5 +12,3 @@ %tr %td= s.first %td= s.second - - diff --git a/config/locales/en.yml b/config/locales/en.yml index a7af25dcf..df6c53b77 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -148,7 +148,6 @@ en: value: taken: 'Status already exists on this domain' - user: attributes: username: @@ -515,7 +514,7 @@ en: crt_revoked: 'CRT (revoked)' contact_org_error: 'Parameter value policy error. Org must be blank' contact_fax_error: 'Parameter value policy error. Fax must be blank' - ident_update_error: 'Parameter value policy error. Update of ident data not allowed' + ident_update_error: 'Parameter value policy error. Update of ident data not allowed [ident]' invoices: 'Invoices' no_such_user: 'No such user' log_in: 'Log in' diff --git a/db/migrate/20150903105659_add_updated_token.rb b/db/migrate/20150903105659_add_updated_token.rb new file mode 100644 index 000000000..9e6418c60 --- /dev/null +++ b/db/migrate/20150903105659_add_updated_token.rb @@ -0,0 +1,5 @@ +class AddUpdatedToken < ActiveRecord::Migration + def change + add_column :contacts, :legacy_ident_updated_at, :datetime + end +end diff --git a/db/migrate/20150921110152_update_contacts_logs.rb b/db/migrate/20150921110152_update_contacts_logs.rb new file mode 100644 index 000000000..a43cb997a --- /dev/null +++ b/db/migrate/20150921110152_update_contacts_logs.rb @@ -0,0 +1,5 @@ +class UpdateContactsLogs < ActiveRecord::Migration + def change + add_column :log_contacts, :legacy_ident_updated_at, :datetime + end +end diff --git a/db/migrate/20150921111842_rename_contact_ident_updator.rb b/db/migrate/20150921111842_rename_contact_ident_updator.rb new file mode 100644 index 000000000..43dc40d9a --- /dev/null +++ b/db/migrate/20150921111842_rename_contact_ident_updator.rb @@ -0,0 +1,6 @@ +class RenameContactIdentUpdator < ActiveRecord::Migration + def change + rename_column :contacts, :legacy_ident_updated_at, :ident_updated_at + rename_column :log_contacts, :legacy_ident_updated_at, :ident_updated_at + end +end diff --git a/db/schema-read-only.rb b/db/schema-read-only.rb index 615e64008..ca244af5f 100644 --- a/db/schema-read-only.rb +++ b/db/schema-read-only.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150915094707) do +ActiveRecord::Schema.define(version: 20150921111842) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -203,6 +203,7 @@ ActiveRecord::Schema.define(version: 20150915094707) do t.hstore "status_notes" t.integer "legacy_history_id" t.integer "copy_from_id" + t.datetime "ident_updated_at" end add_index "contacts", ["code"], name: "index_contacts_on_code", using: :btree @@ -585,15 +586,16 @@ ActiveRecord::Schema.define(version: 20150915094707) do add_index "log_contact_statuses", ["whodunnit"], name: "index_log_contact_statuses_on_whodunnit", using: :btree create_table "log_contacts", force: :cascade do |t| - t.string "item_type", null: false - t.integer "item_id", null: false - t.string "event", null: false + t.string "item_type", null: false + t.integer "item_id", null: false + t.string "event", null: false t.string "whodunnit" t.json "object" t.json "object_changes" t.datetime "created_at" t.string "session" t.json "children" + t.datetime "ident_updated_at" end add_index "log_contacts", ["item_type", "item_id"], name: "index_log_contacts_on_item_type_and_item_id", using: :btree diff --git a/db/structure.sql b/db/structure.sql index 75246ec42..fbe00eb4d 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -598,7 +598,8 @@ CREATE TABLE contacts ( statuses character varying[], status_notes hstore, legacy_history_id integer, - copy_from_id integer + copy_from_id integer, + ident_updated_at timestamp without time zone ); @@ -1502,7 +1503,8 @@ CREATE TABLE log_contacts ( object_changes json, created_at timestamp without time zone, session character varying, - children json + children json, + ident_updated_at timestamp without time zone ); @@ -4934,7 +4936,13 @@ INSERT INTO schema_migrations (version) VALUES ('20150825125118'); INSERT INTO schema_migrations (version) VALUES ('20150827151906'); +INSERT INTO schema_migrations (version) VALUES ('20150903105659'); + INSERT INTO schema_migrations (version) VALUES ('20150910113839'); INSERT INTO schema_migrations (version) VALUES ('20150915094707'); +INSERT INTO schema_migrations (version) VALUES ('20150921110152'); + +INSERT INTO schema_migrations (version) VALUES ('20150921111842'); + diff --git a/doc/schemas/eis-1.0.xsd b/doc/schemas/eis-1.0.xsd index 262281cca..8093c832d 100644 --- a/doc/schemas/eis-1.0.xsd +++ b/doc/schemas/eis-1.0.xsd @@ -90,7 +90,7 @@ - + diff --git a/lib/schemas/eis-1.0.xsd b/lib/schemas/eis-1.0.xsd index 262281cca..8093c832d 100644 --- a/lib/schemas/eis-1.0.xsd +++ b/lib/schemas/eis-1.0.xsd @@ -90,7 +90,7 @@ - + diff --git a/lib/sorted_country.rb b/lib/sorted_country.rb index d05a31bab..1fc514d3f 100644 --- a/lib/sorted_country.rb +++ b/lib/sorted_country.rb @@ -6,7 +6,7 @@ class SortedCountry include ActionView::Helpers def all_options(selected = nil) - quick_options = options_for_select([['', '']] + quick_list, { selected: selected }) + quick_options = options_for_select(quick_list, { selected: selected }) # no double select selected = quick_list.map(&:second).include?(selected) ? '' : selected diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb index 79d96030b..23c180647 100644 --- a/spec/models/contact_spec.rb +++ b/spec/models/contact_spec.rb @@ -116,6 +116,10 @@ describe Contact do @contact.valid? @contact.errors[:email].should == ['Email is invalid'] end + + it 'should have ident updated because the logic itself is dedicated for legacy contacts ' do + @contact.ident_updated_at.should_not == nil + end end context 'with valid attributes' do @@ -234,6 +238,18 @@ describe Contact do contact.status_notes['someotherstatus'].should == nil end + it 'should have ident already updated because the logic itself is only for legacy contacts' do + @contact.ident_updated_at.should_not == nil + end + + it 'should have not update ident updated at when initializing old contact' do + # creating a legacy contact + contact = Fabricate(:contact) + contact.update_column(:ident_updated_at, nil) + + Contact.find(contact.id).ident_updated_at.should == nil + end + context 'as birthday' do before do @domain = Fabricate(:domain) From a1ff4064b3a90fd46138d6b7a777770d1254b04b Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Wed, 23 Sep 2015 12:49:11 +0300 Subject: [PATCH 40/41] rubocop updates --- app/models/depp/contact.rb | 8 +++++++- app/models/epp/contact.rb | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/models/depp/contact.rb b/app/models/depp/contact.rb index d85292bad..0fa9f777a 100644 --- a/app/models/depp/contact.rb +++ b/app/models/depp/contact.rb @@ -230,6 +230,9 @@ module Depp handle_errors(data) end + # rubocop:disable Metrics/CyclomaticComplexity + # rubocop:disable Style/NegatedIf + # rubocop:disable Style/RedundantSelf def extension_xml(action) xml = { _anonymus: [] } @@ -237,7 +240,7 @@ module Depp when :create ident = ident_xml[:_anonymus].try(:first) when :update - # detect if any ident has changed + # detect if any ident has changed, nb! ident and self.ident is not always same if !(ident == self.ident && ident == self.ident_type && ident_country_code == self.ident_country_code) ident = ident_xml[:_anonymus].try(:first) end @@ -248,6 +251,9 @@ module Depp xml[:_anonymus] << legal if legal.present? xml end + # rubocop:enable Metrics/CyclomaticComplexity + # rubocop:enable Style/NegatedIf + # rubocop:enable Style/RedundantSelf def ident_xml { diff --git a/app/models/epp/contact.rb b/app/models/epp/contact.rb index 8054d590b..57bf9192a 100644 --- a/app/models/epp/contact.rb +++ b/app/models/epp/contact.rb @@ -133,6 +133,7 @@ class Epp::Contact < Contact } end + # rubocop:disable Metrics/AbcSize def update_attributes(frame) return super if frame.blank? at = {}.with_indifferent_access @@ -161,6 +162,7 @@ class Epp::Contact < Contact super(at) end + # rubocop:enable Metrics/AbcSize def statuses_attrs(frame, action) status_list = status_list_from(frame) From c5b149d1ce6670aadb034ff240776db42d852b27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Tue, 29 Sep 2015 16:51:03 +0300 Subject: [PATCH 41/41] improved comment for legal doc types #2837 --- config/application-example.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/application-example.yml b/config/application-example.yml index f6f18315e..efc3101a7 100644 --- a/config/application-example.yml +++ b/config/application-example.yml @@ -62,7 +62,8 @@ contact_org_enabled: 'false' # Enable iptables counter updater # iptables_counter_enabled: 'true' -# Custom legal document types +# Custom legal document types. Changing this requires updating EPP extension schema for allowed legalDocEnumType values. +# System default for legal document types is: pdf,bdoc,ddoc,zip,rar,gz,tar,7z,odt,doc,docx # legal_document_types: "pdf,bdoc,ddoc,zip,rar,gz,tar,7z,odt,doc,docx"