Class: Kaui::BundleTagsController
Instance Method Summary
collapse
#check_for_redirect_to_tenant_screen, #current_ability, #current_user, #options_for_klient
Instance Method Details
#edit ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'app/controllers/kaui/bundle_tags_controller.rb', line 17
def edit
bundle_id_or_key = params[:bundle_id]
account_id = params[:account_id]
begin
@bundle = Kaui::Bundle::find_by_id_or_key(bundle_id_or_key, account_id, options_for_klient)
@tag_names = (@bundle.tags(false, 'NONE', options_for_klient).map { |tag| tag.tag_definition_name }).sort
@available_tags = Kaui::TagDefinition.all_for_bundle(options_for_klient)
rescue => e
flash[:error] = "Error while editing tags: #{as_string(e)}"
redirect_to kaui_engine.bundle_tags_path(:bundle_id => bundle_id_or_key)
end
end
|
#show ⇒ Object
3
4
5
6
7
8
9
10
11
12
13
14
15
|
# File 'app/controllers/kaui/bundle_tags_controller.rb', line 3
def show
bundle_id_or_key = params[:bundle_id]
account_id = params[:account_id]
begin
@bundle = Kaui::Bundle::find_by_id_or_key(bundle_id_or_key, account_id, options_for_klient)
@account = Kaui::Account::find_by_id_or_key(@bundle.account_id, false, false, options_for_klient)
@tags = @bundle.tags(true, 'FULL', options_for_klient).sort { |tag_a, tag_b| tag_a <=> tag_b }
rescue => e
flash[:error] = "Error while getting tags: #{as_string(e)}"
redirect_to :back
end
end
|
#update ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'app/controllers/kaui/bundle_tags_controller.rb', line 31
def update
bundle_id = params[:bundle_id]
tags = []
params.each do |tag, tag_name|
tag_info = tag.split('_')
next if tag_info.size != 2 or tag_info[0] != 'tag'
tags << tag_info[1]
end
begin
bundle = Kaui::Bundle.new(:bundle_id => bundle_id)
bundle.set_tags(tags, current_user.kb_username, params[:reason], params[:comment], options_for_klient)
redirect_to kaui_engine.bundle_tags_path(:bundle_id => bundle_id), :notice => 'Bundle tags successfully set'
rescue => e
flash[:error] = "Error while updating tags: #{as_string(e)}"
redirect_to kaui_engine.bundle_tags_path(:bundle_id => bundle_id)
end
end
|