Class: Kaui::AccountTagsController
Instance Method Summary
collapse
#check_for_redirect_to_tenant_screen, #current_ability, #current_user, #options_for_klient
Instance Method Details
#edit ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'app/controllers/kaui/account_tags_controller.rb', line 15
def edit
account_id_or_key = params[:account_id]
begin
@account = Kaui::Account::find_by_id_or_key(account_id_or_key, false, false, options_for_klient)
@tag_names = (@account.tags(false, 'NONE', options_for_klient).map { |tag| tag.tag_definition_name }).sort
@available_tags = Kaui::TagDefinition.all_for_account(options_for_klient)
rescue => e
flash[:error] = "Error while editing tags: #{as_string(e)}"
redirect_to kaui_engine.account_tags_path(:account_id => account_id_or_key)
end
end
|
#show ⇒ Object
3
4
5
6
7
8
9
10
11
12
13
|
# File 'app/controllers/kaui/account_tags_controller.rb', line 3
def show
account_id_or_key = params[:account_id]
begin
@account = Kaui::Account::find_by_id_or_key(account_id_or_key, false, false, options_for_klient)
@tags = @account.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'app/controllers/kaui/account_tags_controller.rb', line 28
def update
account_id = params[:account_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
account = Kaui::Account.new(:account_id => account_id)
account.set_tags(tags, current_user.kb_username, params[:reason], params[:comment], options_for_klient)
redirect_to kaui_engine.account_tags_path(:account_id => account_id), :notice => 'Account tags successfully set'
rescue => e
flash[:error] = "Error while updating tags: #{as_string(e)}"
redirect_to kaui_engine.account_tags_path(:account_id => account_id)
end
end
|