Revision 328c7f27
Added by Ondřej Pražák over 7 years ago
app/controllers/concerns/foreman/controller/taxonomies_controller.rb | ||
---|---|---|
assign_selected_hosts assign_all_hosts step2 select
|
||
parent_taxonomy_selected}
|
||
before_action :count_nil_hosts, :only => %w{index create step2}
|
||
before_action :new_taxonomy, :only => %w{create}
|
||
skip_before_action :authorize, :set_taxonomy, :only => %w{select clear}
|
||
end
|
||
|
||
... | ... | |
end
|
||
|
||
def create
|
||
@taxonomy = taxonomy_class.new(resource_params)
|
||
if @taxonomy.save
|
||
switch_taxonomy
|
||
if @count_nil_hosts > 0
|
||
redirect_to send("step2_#{taxonomy_single}_path",@taxonomy)
|
||
else
|
||
... | ... | |
end
|
||
|
||
def select
|
||
taxonomy_class.current = @taxonomy
|
||
session[taxonomy_id] = @taxonomy ? @taxonomy.id : nil
|
||
|
||
TopbarSweeper.expire_cache(self)
|
||
switch_taxonomy
|
||
redirect_back_or_to root_url
|
||
end
|
||
|
||
... | ... | |
def resource_params
|
||
public_send("#{taxonomy_single}_params".to_sym)
|
||
end
|
||
|
||
def new_taxonomy
|
||
@taxonomy = taxonomy_class.new(resource_params)
|
||
end
|
||
|
||
def switch_taxonomy
|
||
taxonomy_class.current = @taxonomy
|
||
session[taxonomy_id] = @taxonomy ? @taxonomy.id : nil
|
||
|
||
TopbarSweeper.expire_cache(self)
|
||
end
|
||
end
|
Also available in: Unified diff
Fixes #17681 - Switch to newly created taxonomy
(cherry picked from commit 9f68d4d91af0eef381a97dd5c4b33c114282d4e2)