added auction list to admin panel

This commit is contained in:
olegphenomenon 2022-04-08 18:39:47 +03:00
parent faf87aec7a
commit 2aa1100305
12 changed files with 359 additions and 4 deletions

View file

@ -0,0 +1,41 @@
module Admin
class AuctionsController < BaseController
load_and_authorize_resource
def index
params[:q] ||= {}
@auctions = Auction.with_status(params[:statuses_contains])
normalize_search_parameters do
@q = @auctions.ransack(PartialSearchFormatter.format(params[:q]))
@auctions = @q.result.page(params[:page])
end
@auctions = @auctions.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
render_by_format('admin/auctions/index', 'auctions')
end
def update
redirect_to admin_auctions_path
end
private
def normalize_search_parameters
ca_cache = params[:q][:valid_to_lteq]
begin
end_time = params[:q][:valid_to_lteq].try(:to_date)
params[:q][:valid_to_lteq] = end_time.try(:end_of_day)
rescue
logger.warn('Invalid date')
end
yield
params[:q][:valid_to_lteq] = ca_cache
end
end
end