Skip to content

Commit

Permalink
Remove default chargeback method from UI Constants
Browse files Browse the repository at this point in the history
  • Loading branch information
lpichler committed Aug 7, 2017
1 parent 7a13119 commit d37a04f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
10 changes: 7 additions & 3 deletions app/controllers/report_controller/reports/editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ def chargeback_allocated_methods
Hash[CHAREGEBACK_ALLOCATED_METHODS.map { |x| _(x) }]
end

def default_chargeback_allocated_method
chargeback_allocated_methods.keys.first
end

def miq_report_new
assert_privileges("miq_report_new")
@_params.delete :id # incase add button was pressed from report show screen.
Expand Down Expand Up @@ -524,7 +528,7 @@ def gfv_model
@edit[:new][:cb_groupby] ||= "date" # Default to Date grouping
@edit[:new][:tz] = session[:user_tz]
@edit[:new][:cb_include_metrics] = true if @edit[:new][:model] == 'ChargebackVm'
@edit[:new][:method_for_allocated_metrics] = DEFAULT_CHARGEBACK_ALLOCATED_METHOD
@edit[:new][:method_for_allocated_metrics] = default_chargeback_allocated_method
end
reset_report_col_fields
build_edit_screen
Expand Down Expand Up @@ -619,7 +623,7 @@ def gfv_chargeback
elsif params.key?(:cb_include_metrics)
@edit[:new][:cb_include_metrics] = params[:cb_include_metrics] == 'true'
elsif params.key?(:method_for_allocated_metrics)
@edit[:new][:method_for_allocated_metrics] = params[:method_for_allocated_metrics].try(:to_sym) || DEFAULT_CHARGEBACK_ALLOCATED_METHOD
@edit[:new][:method_for_allocated_metrics] = params[:method_for_allocated_metrics].try(:to_sym) || default_chargeback_allocated_method
elsif params.key?(:cb_owner_id)
@edit[:new][:cb_owner_id] = params[:cb_owner_id].blank? ? nil : params[:cb_owner_id]
elsif params.key?(:cb_tenant_id)
Expand Down Expand Up @@ -1306,7 +1310,7 @@ def set_form_vars

# @edit[:new][:cb_include_metrics] = nil - it means YES (YES is default value for new and legacy reports)
@edit[:new][:cb_include_metrics] = options[:include_metrics].nil? || options[:include_metrics]
@edit[:new][:method_for_allocated_metrics] = options[:method_for_allocated_metrics].try(:to_sym) || DEFAULT_CHARGEBACK_ALLOCATED_METHOD
@edit[:new][:method_for_allocated_metrics] = options[:method_for_allocated_metrics].try(:to_sym) || default_chargeback_allocated_method
@edit[:new][:cb_groupby_tag] = options[:groupby_tag] if options.key?(:groupby_tag)
@edit[:new][:cb_model] = Chargeback.report_cb_model(@rpt.db)
@edit[:new][:cb_interval] = options[:interval]
Expand Down
1 change: 0 additions & 1 deletion app/helpers/ui_constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,6 @@ module UiConstants
CHAREGEBACK_ALLOCATED_METHODS = {}
CHAREGEBACK_ALLOCATED_METHODS[:max] = N_('Maximum')
CHAREGEBACK_ALLOCATED_METHODS[:avg] = N_('Average')
DEFAULT_CHARGEBACK_ALLOCATED_METHOD = CHAREGEBACK_ALLOCATED_METHODS.keys.first
end

# Make these constants globally available
Expand Down

0 comments on commit d37a04f

Please sign in to comment.