mirror of
https://github.com/internetee/registry.git
synced 2025-07-29 14:06:21 +02:00
added modal window
This commit is contained in:
parent
2aa1100305
commit
77249629bb
6 changed files with 102 additions and 30 deletions
|
@ -6,6 +6,7 @@ module Admin
|
|||
params[:q] ||= {}
|
||||
|
||||
@auctions = Auction.with_status(params[:statuses_contains])
|
||||
@auction = Auction.new
|
||||
|
||||
normalize_search_parameters do
|
||||
@q = @auctions.ransack(PartialSearchFormatter.format(params[:q]))
|
||||
|
@ -14,16 +15,47 @@ module Admin
|
|||
|
||||
@auctions = @auctions.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
|
||||
|
||||
domains = ReservedDomain.all.order(:name)
|
||||
q = domains.ransack(PartialSearchFormatter.format(params[:q]))
|
||||
@domains = q.result.page(params[:page])
|
||||
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
|
||||
|
||||
render_by_format('admin/auctions/index', 'auctions')
|
||||
end
|
||||
|
||||
def update
|
||||
def create
|
||||
auction = Auction.new(domain: params[:domain], status: Auction.statuses[:started])
|
||||
|
||||
if auction.save
|
||||
remove_from_reserved(auction)
|
||||
flash[:notice] = "Auction #{params[:domain]} created"
|
||||
else
|
||||
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)
|
||||
|
||||
table.each do |row|
|
||||
record = row.to_h
|
||||
auction = Auction.new(domain: record['name'], status: Auction.statuses[:started])
|
||||
remove_from_reserved(auction) if auction.save!
|
||||
end
|
||||
|
||||
redirect_to admin_auctions_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def remove_from_reserved(auction)
|
||||
domain = ReservedDomain.find_by(name: auction.domain)
|
||||
|
||||
domain.destroy if domain.present?
|
||||
end
|
||||
|
||||
def normalize_search_parameters
|
||||
ca_cache = params[:q][:valid_to_lteq]
|
||||
begin
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue