From 185e1d5c93927e1686bc257dc5873ddab451c609 Mon Sep 17 00:00:00 2001 From: Stas Date: Wed, 10 Feb 2016 10:38:47 +0200 Subject: [PATCH 1/6] 110687814-update_function --- app/models/epp/domain.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 3f32ce6d5..62c6ee7ac 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -3,9 +3,11 @@ class Epp::Domain < Domain include EppErrors # TODO: remove this spagetti once data in production is correct. - attr_accessor :is_renewal, :is_transfer + attr_accessor :is_renewal, :is_transfer, :current_user before_validation :manage_permissions + before_update :write_update_values + def manage_permissions return if is_admin # this bad hack for 109086524, refactor later return true if is_transfer || is_renewal @@ -14,6 +16,11 @@ class Epp::Domain < Domain false end + def write_update_values + self.updator_str = current_user.identity_code if current_user + self.updated_at = Time.zone.now + end + after_validation :validate_contacts def validate_contacts return true if is_renewal || is_transfer @@ -488,6 +495,8 @@ class Epp::Domain < Domain # at[:statuses] += at_add[:domain_statuses_attributes] + @current_user = current_user + if errors.empty? && verify && Setting.request_confrimation_on_registrant_change_enabled && frame.css('registrant').present? && From 577762a2bc25b534e8a06c5ff61507d94ec8fa41 Mon Sep 17 00:00:00 2001 From: Stas Date: Thu, 25 Feb 2016 13:54:46 +0200 Subject: [PATCH 2/6] 110687814-migrations_and_values --- app/controllers/epp/contacts_controller.rb | 2 +- app/models/epp/contact.rb | 13 ++++++++++++- app/models/epp/domain.rb | 2 +- .../20160225113801_add_up_id_value_to_domain.rb | 5 +++++ .../20160225113812_add_up_id_value_to_contact.rb | 5 +++++ 5 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20160225113801_add_up_id_value_to_domain.rb create mode 100644 db/migrate/20160225113812_add_up_id_value_to_contact.rb diff --git a/app/controllers/epp/contacts_controller.rb b/app/controllers/epp/contacts_controller.rb index 5b0a39bbf..22473bae7 100644 --- a/app/controllers/epp/contacts_controller.rb +++ b/app/controllers/epp/contacts_controller.rb @@ -29,7 +29,7 @@ class Epp::ContactsController < EppController def update authorize! :update, @contact, @password - if @contact.update_attributes(params[:parsed_frame]) + if @contact.update_attributes(params[:parsed_frame], current_user) render_epp_response 'epp/contacts/update' else handle_errors(@contact) diff --git a/app/models/epp/contact.rb b/app/models/epp/contact.rb index 54806b88d..7727666d2 100644 --- a/app/models/epp/contact.rb +++ b/app/models/epp/contact.rb @@ -1,16 +1,25 @@ class Epp::Contact < Contact include EppErrors + attr_accessor :current_user + # disable STI, there is type column present self.inheritance_column = :sti_disabled before_validation :manage_permissions + before_update :write_update_values + def manage_permissions return unless update_prohibited? || delete_prohibited? add_epp_error('2304', nil, nil, I18n.t(:object_status_prohibits_operation)) false end + def write_update_values + self.upid = current_user.identity_code if current_user + self.updated_at = Time.zone.now + end + class << self # support legacy search def find_by_epp_code(code) @@ -142,7 +151,7 @@ class Epp::Contact < Contact end # rubocop:disable Metrics/AbcSize - def update_attributes(frame) + def update_attributes(frame, current_user) return super if frame.blank? at = {}.with_indifferent_access at.deep_merge!(self.class.attrs_from(frame.css('chg'), new_record: false)) @@ -177,6 +186,8 @@ class Epp::Contact < Contact end end + @current_user = current_user + super(at) end # rubocop:enable Metrics/AbcSize diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 62c6ee7ac..8769acc1e 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -17,7 +17,7 @@ class Epp::Domain < Domain end def write_update_values - self.updator_str = current_user.identity_code if current_user + self.upid = current_user.identity_code if current_user self.updated_at = Time.zone.now end diff --git a/db/migrate/20160225113801_add_up_id_value_to_domain.rb b/db/migrate/20160225113801_add_up_id_value_to_domain.rb new file mode 100644 index 000000000..df3d70e6f --- /dev/null +++ b/db/migrate/20160225113801_add_up_id_value_to_domain.rb @@ -0,0 +1,5 @@ +class AddUpIdValueToDomain < ActiveRecord::Migration + def change + add_column :domains, :upid, :string + end +end diff --git a/db/migrate/20160225113812_add_up_id_value_to_contact.rb b/db/migrate/20160225113812_add_up_id_value_to_contact.rb new file mode 100644 index 000000000..927950bd2 --- /dev/null +++ b/db/migrate/20160225113812_add_up_id_value_to_contact.rb @@ -0,0 +1,5 @@ +class AddUpIdValueToContact < ActiveRecord::Migration + def change + add_column :contacts, :upid, :string + end +end From 7784a44f8de60e6518034b308392cd3ed02d2222 Mon Sep 17 00:00:00 2001 From: Stas Date: Fri, 26 Feb 2016 15:56:51 +0200 Subject: [PATCH 3/6] 110687814-migrations_code_change --- app/models/epp/contact.rb | 9 ++------- app/models/epp/domain.rb | 9 ++------- db/migrate/20160225113801_add_up_id_value_to_domain.rb | 2 +- db/migrate/20160225113812_add_up_id_value_to_contact.rb | 2 +- db/migrate/20160226132045_add_up_date_value_to_domain.rb | 5 +++++ .../20160226132056_add_up_date_value_to_contact.rb | 5 +++++ 6 files changed, 16 insertions(+), 16 deletions(-) create mode 100644 db/migrate/20160226132045_add_up_date_value_to_domain.rb create mode 100644 db/migrate/20160226132056_add_up_date_value_to_contact.rb diff --git a/app/models/epp/contact.rb b/app/models/epp/contact.rb index 7727666d2..303113f02 100644 --- a/app/models/epp/contact.rb +++ b/app/models/epp/contact.rb @@ -7,7 +7,6 @@ class Epp::Contact < Contact self.inheritance_column = :sti_disabled before_validation :manage_permissions - before_update :write_update_values def manage_permissions return unless update_prohibited? || delete_prohibited? @@ -15,11 +14,6 @@ class Epp::Contact < Contact false end - def write_update_values - self.upid = current_user.identity_code if current_user - self.updated_at = Time.zone.now - end - class << self # support legacy search def find_by_epp_code(code) @@ -186,7 +180,8 @@ class Epp::Contact < Contact end end - @current_user = current_user + self.upid = current_user.id if current_user + self.update = Time.zone.now super(at) end diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 8769acc1e..aca475cf5 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -6,7 +6,6 @@ class Epp::Domain < Domain attr_accessor :is_renewal, :is_transfer, :current_user before_validation :manage_permissions - before_update :write_update_values def manage_permissions return if is_admin # this bad hack for 109086524, refactor later @@ -16,11 +15,6 @@ class Epp::Domain < Domain false end - def write_update_values - self.upid = current_user.identity_code if current_user - self.updated_at = Time.zone.now - end - after_validation :validate_contacts def validate_contacts return true if is_renewal || is_transfer @@ -495,7 +489,8 @@ class Epp::Domain < Domain # at[:statuses] += at_add[:domain_statuses_attributes] - @current_user = current_user + self.upid = current_user.id if current_user + self.update = Time.zone.now if errors.empty? && verify && Setting.request_confrimation_on_registrant_change_enabled && diff --git a/db/migrate/20160225113801_add_up_id_value_to_domain.rb b/db/migrate/20160225113801_add_up_id_value_to_domain.rb index df3d70e6f..9879c8555 100644 --- a/db/migrate/20160225113801_add_up_id_value_to_domain.rb +++ b/db/migrate/20160225113801_add_up_id_value_to_domain.rb @@ -1,5 +1,5 @@ class AddUpIdValueToDomain < ActiveRecord::Migration def change - add_column :domains, :upid, :string + add_column :domains, :upid, :integer end end diff --git a/db/migrate/20160225113812_add_up_id_value_to_contact.rb b/db/migrate/20160225113812_add_up_id_value_to_contact.rb index 927950bd2..b78478e75 100644 --- a/db/migrate/20160225113812_add_up_id_value_to_contact.rb +++ b/db/migrate/20160225113812_add_up_id_value_to_contact.rb @@ -1,5 +1,5 @@ class AddUpIdValueToContact < ActiveRecord::Migration def change - add_column :contacts, :upid, :string + add_column :contacts, :upid, :integer end end diff --git a/db/migrate/20160226132045_add_up_date_value_to_domain.rb b/db/migrate/20160226132045_add_up_date_value_to_domain.rb new file mode 100644 index 000000000..c3568e6dd --- /dev/null +++ b/db/migrate/20160226132045_add_up_date_value_to_domain.rb @@ -0,0 +1,5 @@ +class AddUpDateValueToDomain < ActiveRecord::Migration + def change + add_column :domains, :update, :timestamp + end +end diff --git a/db/migrate/20160226132056_add_up_date_value_to_contact.rb b/db/migrate/20160226132056_add_up_date_value_to_contact.rb new file mode 100644 index 000000000..99f90d662 --- /dev/null +++ b/db/migrate/20160226132056_add_up_date_value_to_contact.rb @@ -0,0 +1,5 @@ +class AddUpDateValueToContact < ActiveRecord::Migration + def change + add_column :contacts, :update, :timestamp + end +end From 003bfed538552ab64903a0d7e8423064dc200a11 Mon Sep 17 00:00:00 2001 From: Stas Date: Fri, 26 Feb 2016 16:52:08 +0200 Subject: [PATCH 4/6] 110687814-attr_accessor_removed --- app/models/epp/contact.rb | 2 -- app/models/epp/domain.rb | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/app/models/epp/contact.rb b/app/models/epp/contact.rb index 303113f02..725d8d2a2 100644 --- a/app/models/epp/contact.rb +++ b/app/models/epp/contact.rb @@ -1,8 +1,6 @@ class Epp::Contact < Contact include EppErrors - attr_accessor :current_user - # disable STI, there is type column present self.inheritance_column = :sti_disabled diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index aca475cf5..104abeb57 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -3,7 +3,7 @@ class Epp::Domain < Domain include EppErrors # TODO: remove this spagetti once data in production is correct. - attr_accessor :is_renewal, :is_transfer, :current_user + attr_accessor :is_renewal, :is_transfer before_validation :manage_permissions From 5cc3e0d1dee35b23c7a3d05acf125341ec86dd04 Mon Sep 17 00:00:00 2001 From: Stas Date: Wed, 2 Mar 2016 18:34:56 +0200 Subject: [PATCH 5/6] 110687814-name_fix --- db/migrate/20160226132045_add_up_date_value_to_domain.rb | 2 +- db/migrate/20160226132056_add_up_date_value_to_contact.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/db/migrate/20160226132045_add_up_date_value_to_domain.rb b/db/migrate/20160226132045_add_up_date_value_to_domain.rb index c3568e6dd..5fdc3d196 100644 --- a/db/migrate/20160226132045_add_up_date_value_to_domain.rb +++ b/db/migrate/20160226132045_add_up_date_value_to_domain.rb @@ -1,5 +1,5 @@ class AddUpDateValueToDomain < ActiveRecord::Migration def change - add_column :domains, :update, :timestamp + add_column :domains, :up_date, :timestamp end end diff --git a/db/migrate/20160226132056_add_up_date_value_to_contact.rb b/db/migrate/20160226132056_add_up_date_value_to_contact.rb index 99f90d662..f7ba92313 100644 --- a/db/migrate/20160226132056_add_up_date_value_to_contact.rb +++ b/db/migrate/20160226132056_add_up_date_value_to_contact.rb @@ -1,5 +1,5 @@ class AddUpDateValueToContact < ActiveRecord::Migration def change - add_column :contacts, :update, :timestamp + add_column :contacts, :up_date, :timestamp end end From 9926a7e54c8e6da4443f1e4ea66fc0c27f71177d Mon Sep 17 00:00:00 2001 From: Stas Date: Wed, 2 Mar 2016 18:46:08 +0200 Subject: [PATCH 6/6] 110687814-variable_changes --- app/models/epp/contact.rb | 2 +- app/models/epp/domain.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/epp/contact.rb b/app/models/epp/contact.rb index 725d8d2a2..6a3540888 100644 --- a/app/models/epp/contact.rb +++ b/app/models/epp/contact.rb @@ -179,7 +179,7 @@ class Epp::Contact < Contact end self.upid = current_user.id if current_user - self.update = Time.zone.now + self.up_date = Time.zone.now super(at) end diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 104abeb57..b92a33e5a 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -490,7 +490,7 @@ class Epp::Domain < Domain # at[:statuses] += at_add[:domain_statuses_attributes] self.upid = current_user.id if current_user - self.update = Time.zone.now + self.up_date = Time.zone.now if errors.empty? && verify && Setting.request_confrimation_on_registrant_change_enabled &&