mirror of
https://github.com/internetee/registry.git
synced 2025-06-08 21:54:48 +02:00
parent
8c4e6f1656
commit
83f8a9fb6a
44 changed files with 530 additions and 610 deletions
|
@ -1,21 +1,19 @@
|
|||
class Registrant::ContactsController < RegistrantController
|
||||
helper_method :domain_ids
|
||||
helper_method :domain
|
||||
helper_method :fax_enabled?
|
||||
skip_authorization_check only: %i[edit update]
|
||||
|
||||
def show
|
||||
@contact = Contact.where(id: contacts).find_by(id: params[:id])
|
||||
|
||||
@contact = current_user_contacts.find(params[:id])
|
||||
authorize! :read, @contact
|
||||
end
|
||||
|
||||
def edit
|
||||
@contact = Contact.where(id: contacts).find(params[:id])
|
||||
@contact = current_user_contacts.find(params[:id])
|
||||
end
|
||||
|
||||
def update
|
||||
@contact = Contact.where(id: contacts).find(params[:id])
|
||||
@contact = current_user_contacts.find(params[:id])
|
||||
@contact.attributes = contact_params
|
||||
response = update_contact_via_api(@contact.uuid)
|
||||
updated = response.is_a?(Net::HTTPSuccess)
|
||||
|
@ -31,38 +29,10 @@ class Registrant::ContactsController < RegistrantController
|
|||
|
||||
private
|
||||
|
||||
def contacts
|
||||
begin
|
||||
DomainContact.where(domain_id: domain_ids).pluck(:contact_id) | Domain.where(id: domain_ids).pluck(:registrant_id)
|
||||
rescue Soap::Arireg::NotAvailableError => error
|
||||
flash[:notice] = I18n.t(error.json[:message])
|
||||
Rails.logger.fatal("[EXCEPTION] #{error.to_s}")
|
||||
[]
|
||||
end
|
||||
end
|
||||
|
||||
def domain_ids
|
||||
@domain_ids ||= begin
|
||||
ident_cc, ident = current_registrant_user.registrant_ident.to_s.split '-'
|
||||
BusinessRegistryCache.fetch_by_ident_and_cc(ident, ident_cc).associated_domain_ids
|
||||
end
|
||||
end
|
||||
|
||||
def domain
|
||||
current_user_domains.find(params[:domain_id])
|
||||
end
|
||||
|
||||
def current_user_domains
|
||||
ident_cc, ident = current_registrant_user.registrant_ident.split '-'
|
||||
begin
|
||||
BusinessRegistryCache.fetch_associated_domains ident, ident_cc
|
||||
rescue Soap::Arireg::NotAvailableError => error
|
||||
flash[:notice] = I18n.t(error.json[:message])
|
||||
Rails.logger.fatal("[EXCEPTION] #{error.to_s}")
|
||||
current_registrant_user.domains
|
||||
end
|
||||
end
|
||||
|
||||
def contact_params
|
||||
permitted = %i[
|
||||
name
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue