mirror of
https://github.com/internetee/registry.git
synced 2025-05-16 17:37:17 +02:00
110687814-migrations_and_values
This commit is contained in:
parent
185e1d5c93
commit
577762a2bc
5 changed files with 24 additions and 3 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
5
db/migrate/20160225113801_add_up_id_value_to_domain.rb
Normal file
5
db/migrate/20160225113801_add_up_id_value_to_domain.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class AddUpIdValueToDomain < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :domains, :upid, :string
|
||||
end
|
||||
end
|
5
db/migrate/20160225113812_add_up_id_value_to_contact.rb
Normal file
5
db/migrate/20160225113812_add_up_id_value_to_contact.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class AddUpIdValueToContact < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :contacts, :upid, :string
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue