mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 09:57:23 +02:00
parent
8916eee169
commit
f76e1259fc
11 changed files with 106 additions and 65 deletions
|
@ -6,18 +6,19 @@ module Admin
|
|||
helper_method :zones
|
||||
helper_method :operation_categories
|
||||
helper_method :durations
|
||||
helper_method :statuses
|
||||
|
||||
def index
|
||||
@search = OpenStruct.new(search_params)
|
||||
|
||||
unless @search.validity
|
||||
@search.validity = 'unexpired'
|
||||
unless @search.status
|
||||
@search.status = default_status
|
||||
end
|
||||
|
||||
prices = ::Billing::Price.all
|
||||
|
||||
if @search.validity.present?
|
||||
prices = ::Billing::Price.send(@search.validity)
|
||||
if @search.status.present?
|
||||
prices = ::Billing::Price.send(@search.status)
|
||||
end
|
||||
|
||||
@q = prices.search(params[:q])
|
||||
|
@ -81,7 +82,7 @@ module Admin
|
|||
|
||||
def search_params
|
||||
allowed_params = %i[
|
||||
validity
|
||||
status
|
||||
]
|
||||
params.fetch(:search, {}).permit(*allowed_params)
|
||||
end
|
||||
|
@ -102,6 +103,14 @@ module Admin
|
|||
durations = ::Billing::Price::durations
|
||||
durations.collect { |duration| [duration.sub('mon', 'month'), duration] }
|
||||
end
|
||||
|
||||
def statuses
|
||||
::Billing::Price.statuses
|
||||
end
|
||||
|
||||
def default_status
|
||||
'effective'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue