Class: Kaui::BundleTagsController

Inherits:
EngineController show all
Defined in:
app/controllers/kaui/bundle_tags_controller.rb

Instance Method Summary collapse

Methods inherited from EngineController

#current_user

Methods included from ErrorHelper

#as_string

Instance Method Details

#editObject



16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/kaui/bundle_tags_controller.rb', line 16

def edit
  @bundle_id = params[:bundle_id]
  begin
    @available_tags = Kaui::KillbillHelper::get_tag_definitions.sort {|tag_a, tag_b| tag_a.name.downcase <=> tag_b.name.downcase }

    @bundle = Kaui::KillbillHelper::get_bundle(@bundle_id)
    @tags = Kaui::KillbillHelper::get_tags_for_bundle(@bundle_id)
  rescue => e
    flash[:error] = "Error while retrieving tags information: #{as_string(e)}"
  end
end

#showObject



3
4
5
6
7
8
9
10
11
12
13
14
# File 'app/controllers/kaui/bundle_tags_controller.rb', line 3

def show
  bundle_id = params[:id]
  if bundle_id.present?
    begin
      tags = Kaui::KillbillHelper::get_tags_for_bundle(bundle_id)
    rescue => e
      flash[:error] = "Error while retrieving tags information: #{as_string(e)}"
    end
  else
    flash[:error] = "No account id given"
  end
end

#updateObject



28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/kaui/bundle_tags_controller.rb', line 28

def update
  begin
    bundle = Kaui::KillbillHelper::get_bundle(params[:bundle_id])
    tags = params[:tags]

    Kaui::KillbillHelper::set_tags_for_bundle(bundle.bundle_id, tags)
    redirect_to Kaui.bundle_home_path.call(bundle.bundle_id)
  rescue => e
    flash[:error] = "Error while updating tags: #{as_string(e)}"
  end
end