mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 06:34:46 +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
|
||||
|
|
|
@ -1,22 +1,24 @@
|
|||
class Registrant::DomainsController < RegistrantController
|
||||
def index
|
||||
authorize! :view, :registrant_domains
|
||||
|
||||
params[:q] ||= {}
|
||||
normalize_search_parameters do
|
||||
@q = domains.search(params[:q])
|
||||
@q = current_user_domains.search(params[:q])
|
||||
@domains = @q.result.page(params[:page])
|
||||
end
|
||||
|
||||
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
|
||||
end
|
||||
|
||||
def show
|
||||
@domain = domains.find(params[:id])
|
||||
@domain = current_user_domains.find(params[:id])
|
||||
authorize! :read, @domain
|
||||
end
|
||||
|
||||
def domain_verification_url
|
||||
authorize! :view, :registrant_domains
|
||||
dom = domains.find(params[:id])
|
||||
dom = current_user_domains.find(params[:id])
|
||||
if (dom.statuses.include?(DomainStatus::PENDING_UPDATE) || dom.statuses.include?(DomainStatus::PENDING_DELETE_CONFIRMATION)) &&
|
||||
dom.pending_json.present?
|
||||
|
||||
|
@ -34,7 +36,7 @@ class Registrant::DomainsController < RegistrantController
|
|||
authorize! :view, :registrant_domains
|
||||
params[:q] ||= {}
|
||||
normalize_search_parameters do
|
||||
@q = domains.search(params[:q])
|
||||
@q = current_user_domains.search(params[:q])
|
||||
@domains = @q
|
||||
end
|
||||
|
||||
|
@ -49,21 +51,6 @@ class Registrant::DomainsController < RegistrantController
|
|||
|
||||
private
|
||||
|
||||
def set_domain
|
||||
@domain = domains.find(params[:id])
|
||||
end
|
||||
|
||||
def 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 normalize_search_parameters
|
||||
ca_cache = params[:q][:valid_to_lteq]
|
||||
begin
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue