From a52119daf06baf02df8f4f0c785a5bc7272dff68 Mon Sep 17 00:00:00 2001 From: olegphenomenon Date: Wed, 27 Apr 2022 14:25:17 +0300 Subject: [PATCH] fixed sorting and message --- app/controllers/admin/auctions_controller.rb | 18 +++++++++++++----- app/views/admin/auctions/index.html.erb | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/controllers/admin/auctions_controller.rb b/app/controllers/admin/auctions_controller.rb index 5f2ff69cf..c1023b705 100644 --- a/app/controllers/admin/auctions_controller.rb +++ b/app/controllers/admin/auctions_controller.rb @@ -43,8 +43,9 @@ module Admin end if auction.save - remove_from_reserved(auction) - flash[:notice] = "Auction #{params[:domain]} created" + reserved_domain = auction.domain if remove_from_reserved(auction) + flash[:notice] = "Auction #{params[:domain]} created. + #{reserved_domain.present? ? 'These domain will be removed from reserved list: ' + reserved_domain : ' '}" else flash[:alert] = 'Something goes wrong' end @@ -62,6 +63,7 @@ module Admin table = CSV.parse(File.read(filename), headers: true) failed_names = [] + reserved_domains = [] if validate_table(table) table.each do |row| @@ -81,11 +83,17 @@ module Admin end auction = Auction.new(domain: record['name'], status: Auction.statuses[:started], platform: 'manual') - remove_from_reserved(auction) if auction.save! + flag = remove_from_reserved(auction) if auction.save! + reserved_domains << auction.domain if flag end - flash[:notice] = 'Domains added!' - flash[:notice] = "Domains added! But these domains were ignored: #{failed_names.join(' ')}" if failed_names.present? + message_template = "Domains added! + #{reserved_domains.present? ? + 'These domains will be removed from reserved list: ' + reserved_domains.join(' ') + '! ' + : '! '} + #{failed_names.present? ? 'These domains were ignored: ' + failed_names.join(' ') : '!'}" + + flash[:notice] = message_template else flash[:alert] = "Invalid CSV format. Should be column with 'name' where is the list of name of domains!" end diff --git a/app/views/admin/auctions/index.html.erb b/app/views/admin/auctions/index.html.erb index 59063865e..551be567f 100644 --- a/app/views/admin/auctions/index.html.erb +++ b/app/views/admin/auctions/index.html.erb @@ -115,7 +115,7 @@ <%= sort_link(@q, 'registration_deadline') %> - <%= sort_link(@q, 'type') %> + <%= sort_link(@q, 'platform', 'Type') %>