Fix CC issues

This commit is contained in:
Alex Sherman 2021-02-05 15:27:10 +05:00
parent fbad7b00b2
commit 3979fc5f8f
4 changed files with 65 additions and 95 deletions

View file

@ -1,12 +1,12 @@
class Registrar
class TechContactsController < BulkChangeController
BASE_URL = URI.parse("#{ENV['repp_url']}domains/contacts").freeze
ACTIVE_TAB = :technical_contact
def update
authorize! :manage, :repp
uri = BASE_URL
request = Net::HTTP::Patch.new(uri)
request.set_form_data(current_contact_id: params[:current_contact_id],
new_contact_id: params[:new_contact_id])
@ -15,25 +15,11 @@ class Registrar
response = do_request(request, uri)
parsed_response = JSON.parse(response.body, symbolize_names: true)
start_notice = t('registrar.tech_contacts.process_request.replaced')
if response.code == '200'
notices = [t('.replaced')]
notices << "#{t('.affected_domains')}: " \
"#{parsed_response[:data][:affected_domains].join(', ')}"
if parsed_response[:data][:skipped_domains]
notices << "#{t('.skipped_domains')}: " \
"#{parsed_response[:data][:skipped_domains].join(', ')}"
end
flash[:notice] = notices.join(', ')
redirect_to registrar_domains_url
else
@error = response.code == '404' ? 'Contact(s) not found' : parsed_response[:message]
render file: 'registrar/bulk_change/new', locals: { active_tab: :technical_contact }
end
process_response(response: response,
start_notice: start_notice,
active_tab: ACTIVE_TAB)
end
end
end