Class: Katello::Api::V2::ContentViewFiltersController
Constant Summary
Concerns::FilteredAutoCompleteSearch::PAGE_SIZE
Instance Method Summary
collapse
#auto_complete_search
#check_katello_agent_not_disabled, #deprecate_katello_agent, #empty_search_query?, #full_result_response, #katello_agent_removal_release, #resource_class, #scoped_search, #skip_session
Methods included from Rendering
#respond_for_async, #respond_for_bulk_async, #respond_for_create, #respond_for_destroy, #respond_for_index, #respond_for_show, #respond_for_status, #respond_for_update, #respond_with_template, #respond_with_template_collection, #respond_with_template_resource, #try_specific_collection_template, #try_specific_resource_template
#api_version
Instance Method Details
#add_filter_rules ⇒ Object
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
# File 'app/controllers/katello/api/v2/content_view_filters_controller.rb', line 116
def add_filter_rules
rule_clazz = ContentViewFilter.rule_class_for(@filter)
rules = []
rules_params[:rules_params].each do |rule_params|
rules = (rule_params[:name] || []).map do |name|
rule_clazz.create!(rule_params.except(:name).merge(:filter => @filter, name: name))
end
rules += (rule_params[:errata_ids] || []).map do |errata_id|
rule_clazz.create!(rule_params.except(:errata_ids)
.merge(filter: @filter, errata_id: errata_id))
end
if rule_params[:module_stream_ids]
rules += (rule_params[:module_stream_ids] || []).map do |module_stream_id|
rule_clazz.create!(rule_params.except(:module_stream_ids)
.merge(filter: @filter, module_stream_id: module_stream_id))
end
end
if rules.empty?
rules = [rule_clazz.create!(rule_params.merge(:filter => @filter))]
end
end
respond_for_show(resource: @filter)
end
|
#create ⇒ Object
45
46
47
48
49
|
# File 'app/controllers/katello/api/v2/content_view_filters_controller.rb', line 45
def create
params[:type] = "erratum" if (params[:type] == "erratum_date" || params[:type] == "erratum_id")
filter = ContentViewFilter.create_for(params[:type], filter_params.merge(:content_view => @view))
respond :resource => filter
end
|
#destroy ⇒ Object
81
82
83
84
|
# File 'app/controllers/katello/api/v2/content_view_filters_controller.rb', line 81
def destroy
@filter.destroy
respond_for_show :resource => @filter
end
|
#index ⇒ Object
17
18
19
|
# File 'app/controllers/katello/api/v2/content_view_filters_controller.rb', line 17
def index
respond(:collection => scoped_search(index_relation.distinct, :name, :asc))
end
|
#index_relation ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
|
# File 'app/controllers/katello/api/v2/content_view_filters_controller.rb', line 21
def index_relation
query = ContentViewFilter.where(:content_view_id => (@view || ContentView.readable))
query = query.where(:name => params[:name]) if params[:name]
if params[:types]
types = params[:types].collect do |type|
::Katello::ContentViewFilter.class_for(type)
end
query = query.where("#{::Katello::ContentViewFilter.table_name}.type IN (?)", types)
end
query
end
|
#remove_filter_rules ⇒ Object
91
92
93
94
95
|
# File 'app/controllers/katello/api/v2/content_view_filters_controller.rb', line 91
def remove_filter_rules
rule_clazz = ContentViewFilter.rule_class_for(@filter)
rule_clazz.where(id: params[:rule_ids]).try(:destroy_all)
respond_for_show(resource: @filter)
end
|
#show ⇒ Object
55
56
57
|
# File 'app/controllers/katello/api/v2/content_view_filters_controller.rb', line 55
def show
respond :resource => @filter
end
|
#update ⇒ Object
72
73
74
75
|
# File 'app/controllers/katello/api/v2/content_view_filters_controller.rb', line 72
def update
@filter.update!(filter_params)
respond :resource => @filter
end
|