This commit is contained in:
Alex Sherman 2021-02-05 15:59:34 +05:00
parent 3979fc5f8f
commit 489cd2f7e5
4 changed files with 23 additions and 11 deletions

View file

@ -26,19 +26,11 @@ class Registrar
private private
def process_response(response:, start_notice: "", active_tab:) def process_response(response:, start_notice: '', active_tab:)
parsed_response = JSON.parse(response.body, symbolize_names: true) parsed_response = JSON.parse(response.body, symbolize_names: true)
if response.code == '200' if response.code == '200'
notices = [start_notice] notices = success_notices(parsed_response, start_notice)
notices << "#{t('registrar.tech_contacts.process_request.affected_domains')}: " \
"#{parsed_response[:data][:affected_domains].join(', ')}"
if parsed_response[:data][:skipped_domains]
notices << "#{t('registrar.tech_contacts.process_request.skipped_domains')}: " \
"#{parsed_response[:data][:skipped_domains].join(', ')}"
end
flash[:notice] = notices.join(', ') flash[:notice] = notices.join(', ')
redirect_to registrar_domains_url redirect_to registrar_domains_url
@ -48,6 +40,19 @@ class Registrar
end end
end end
def success_notices(parsed_response, start_notice)
notices = [start_notice]
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
notices
end
def do_request(request, uri) def do_request(request, uri)
response = if Rails.env.test? response = if Rails.env.test?
do_test_request(request, uri) do_test_request(request, uri)

View file

@ -15,7 +15,7 @@ class Registrar
response = do_request(request, uri) response = do_request(request, uri)
start_notice = t('registrar.tech_contacts.process_request.replaced') start_notice = t('.replaced')
process_response(response: response, process_response(response: response,
start_notice: start_notice, start_notice: start_notice,

View file

@ -4,6 +4,7 @@ en:
new: new:
header: Bulk change header: Bulk change
technical_contact: Technical contact technical_contact: Technical contact
admin_contact: Admin contact
nameserver: Nameserver nameserver: Nameserver
bulk_transfer: Bulk transfer bulk_transfer: Bulk transfer
bulk_renew: Bulk renew bulk_renew: Bulk renew
@ -38,3 +39,5 @@ en:
domain_ids: Domains for bulk renewal domain_ids: Domains for bulk renewal
current_balance: Current balance current_balance: Current balance
period: Period period: Period
affected_domains: Affected domains
skipped_domains: Skipped domains

View file

@ -5,3 +5,7 @@ en:
replaced: Technical contacts have been successfully replaced. replaced: Technical contacts have been successfully replaced.
affected_domains: Affected domains affected_domains: Affected domains
skipped_domains: Skipped domains skipped_domains: Skipped domains
process_request:
affected_domains: Affected domains
skipped_domains: Skipped domains
replaced: Technical contacts have been successfully replaced.