Module: Foreman::Controller::Parameters::TemplateParams

Extended by:
ActiveSupport::Concern
Includes:
Taxonomix
Included in:
Api::V2::TemplateController, UITemplateSyncsController
Defined in:
app/controllers/concerns/foreman/controller/parameters/template_params.rb

Instance Method Summary collapse

Instance Method Details

#base_export_params(toplevel_key) ⇒ Object



69
70
71
72
# File 'app/controllers/concerns/foreman/controller/parameters/template_params.rb', line 69

def base_export_params(toplevel_key)
  self.class.template_params_filter(self.class.extra_export_params)
      .filter_params(params, parameter_filter_context, toplevel_key).with_indifferent_access
end

#base_import_params(toplevel_key) ⇒ Object



64
65
66
67
# File 'app/controllers/concerns/foreman/controller/parameters/template_params.rb', line 64

def base_import_params(toplevel_key)
  self.class.template_params_filter(self.class.extra_import_params)
      .filter_params(params, parameter_filter_context, toplevel_key).with_indifferent_access
end

#location_paramsObject



78
79
80
# File 'app/controllers/concerns/foreman/controller/parameters/template_params.rb', line 78

def location_params
  self.class.location_params_filter(Hash).filter_params(params, parameter_filter_context, :none)
end

#log_deprecated_param(value) ⇒ Object



56
57
58
# File 'app/controllers/concerns/foreman/controller/parameters/template_params.rb', line 56

def log_deprecated_param(value)
  Logging.logger('app').warn "Using '#{value}' as a value for lock when syncing templates is deprecated and will be removed in the future."
end

#organization_paramsObject



74
75
76
# File 'app/controllers/concerns/foreman/controller/parameters/template_params.rb', line 74

def organization_params
  self.class.organization_params_filter(Hash).filter_params(params, parameter_filter_context, :none)
end

#template_export_paramsObject



60
61
62
# File 'app/controllers/concerns/foreman/controller/parameters/template_params.rb', line 60

def template_export_params
  add_taxonomy_params(base_export_params(:none))
end

#template_import_paramsObject



36
37
38
# File 'app/controllers/concerns/foreman/controller/parameters/template_params.rb', line 36

def template_import_params
  transform_lock_param add_taxonomy_params(base_import_params(:none))
end

#transform_lock_param(params) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'app/controllers/concerns/foreman/controller/parameters/template_params.rb', line 40

def transform_lock_param(params)
  lock = params[:lock]
  return params if lock.nil?

  if lock == "true" || lock.is_a?(TrueClass) || lock.to_s == "1"
    log_deprecated_param(lock)
    params[:lock] = "lock"
  end

  if lock == "false" || lock.is_a?(FalseClass) || lock.to_s == "0"
    log_deprecated_param(lock)
    params[:lock] = "unlock"
  end
  params
end

#ui_template_export_paramsObject



32
33
34
# File 'app/controllers/concerns/foreman/controller/parameters/template_params.rb', line 32

def ui_template_export_params
  base_export_params :ui_template_sync
end

#ui_template_import_paramsObject



28
29
30
# File 'app/controllers/concerns/foreman/controller/parameters/template_params.rb', line 28

def ui_template_import_params
  base_import_params :ui_template_sync
end