diff --git a/app/controllers/admin/auctions_controller.rb b/app/controllers/admin/auctions_controller.rb index ca3065108..fc89c01f7 100644 --- a/app/controllers/admin/auctions_controller.rb +++ b/app/controllers/admin/auctions_controller.rb @@ -24,24 +24,25 @@ module Admin end def create - auction = Auction.new(domain: params[:domain], status: Auction.statuses[:started], platform: :english) + auction = Auction.new(domain: params[:domain], status: Auction.statuses[:started], platform: 'english') if auction.save remove_from_reserved(auction) flash[:notice] = "Auction #{params[:domain]} created" else - flash[:alert] = "Something goes wrong" + flash[:alert] = 'Something goes wrong' end redirect_to admin_auctions_path end def upload_spreadsheet - table = CSV.parse(File.read(params[:q][:file]), headers: true) + filename = params[:q][:file] + table = CSV.parse(File.read(filename), headers: true) table.each do |row| record = row.to_h - auction = Auction.new(domain: record['name'], status: Auction.statuses[:started], platform: :english) + auction = Auction.new(domain: record['name'], status: Auction.statuses[:started], platform: 'english') remove_from_reserved(auction) if auction.save! end diff --git a/app/controllers/admin/reserved_domains_controller.rb b/app/controllers/admin/reserved_domains_controller.rb index 2e5cff63c..2daa6e068 100644 --- a/app/controllers/admin/reserved_domains_controller.rb +++ b/app/controllers/admin/reserved_domains_controller.rb @@ -58,7 +58,7 @@ module Admin reserved_domains = ReservedDomain.where(id: reserved_domains_ids) reserved_domains.each do |domain| - Auction.create!(domain: domain.name, status: Auction.statuses[:started], platform: :english) + Auction.create!(domain: domain.name, status: Auction.statuses[:started], platform: 'english') domain.destroy! end diff --git a/app/helpers/auction_helper.rb b/app/helpers/auction_helper.rb index e4ef44736..25cf463af 100644 --- a/app/helpers/auction_helper.rb +++ b/app/helpers/auction_helper.rb @@ -1,7 +1,5 @@ module AuctionHelper include ActionView::Helpers::TagHelper - - extend self def colorize_auction(auction) case auction.status @@ -12,10 +10,10 @@ module AuctionHelper end def render_status_black(name) - content_tag(:span, name.to_s, style: 'color: black;') + tag.span name.to_s, style: 'color: black;' end def render_status_green(name) - content_tag(:span, name.to_s , style: 'color: green;') + tag.span name.to_s, style: 'color: green;' end end diff --git a/app/models/auction.rb b/app/models/auction.rb index 208425f4d..56acba7c6 100644 --- a/app/models/auction.rb +++ b/app/models/auction.rb @@ -9,7 +9,7 @@ class Auction < ApplicationRecord domain_not_registered: 'domain_not_registered', } - enum type: %i[blind english] + enum platform: %i[blind english] PENDING_STATUSES = [statuses[:started], statuses[:awaiting_payment], @@ -17,7 +17,7 @@ class Auction < ApplicationRecord private_constant :PENDING_STATUSES - scope :with_status, -> (status) { + scope :with_status, ->(status) { where(status: status) if status.present? } diff --git a/app/models/dns/domain_name.rb b/app/models/dns/domain_name.rb index 3fe4760ac..f914e3439 100644 --- a/app/models/dns/domain_name.rb +++ b/app/models/dns/domain_name.rb @@ -35,7 +35,7 @@ module DNS def sell_at_auction auction = Auction.new auction.domain = name - auction.platform = :blind + auction.platform = 'blind' auction.start ToStdout.msg "Created the auction: #{auction.inspect}" update_whois_from_auction(auction) diff --git a/app/views/admin/auctions/index.html.erb b/app/views/admin/auctions/index.html.erb index 2ea206671..52472e7fa 100644 --- a/app/views/admin/auctions/index.html.erb +++ b/app/views/admin/auctions/index.html.erb @@ -124,7 +124,7 @@ <% @auctions.each do |auction| %> - <%= AuctionHelper.colorize_auction(auction) %> + <%= colorize_auction(auction) %> <%= auction.status %> <%= auction.created_at %> <%= auction.registration_code %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 28d2d0281..c36dcadeb 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -189,6 +189,7 @@ en: log_out: 'Log out (%{user})' system: 'System' domains: 'Domains' + auctions: 'Auctions' registrars: 'Registrars' valid_to: 'Valid to' name: 'Name' diff --git a/db/migrate/20220412130856_add_type_to_auction.rb b/db/migrate/20220412130856_add_type_to_auction.rb index a48ca5ed9..14714e868 100644 --- a/db/migrate/20220412130856_add_type_to_auction.rb +++ b/db/migrate/20220412130856_add_type_to_auction.rb @@ -1,5 +1,5 @@ class AddTypeToAuction < ActiveRecord::Migration[6.1] def change - # add_column :auctions, :type, :integer, null: true + add_column :auctions, :platform, :integer, null: true end end diff --git a/db/structure.sql b/db/structure.sql index 74d2802bb..8512da48e 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -337,7 +337,8 @@ CREATE TABLE public.auctions ( uuid uuid DEFAULT public.gen_random_uuid() NOT NULL, created_at timestamp without time zone NOT NULL, registration_code character varying, - registration_deadline timestamp without time zone + registration_deadline timestamp without time zone, + platform integer );