Class: Kaui::BundlesController
- Inherits:
-
EngineController
- Object
- ApplicationController
- EngineController
- Kaui::BundlesController
- Defined in:
- app/controllers/kaui/bundles_controller.rb
Instance Method Summary collapse
Methods inherited from EngineController
#check_for_redirect_to_tenant_screen, #current_ability, #current_user, #options_for_klient
Instance Method Details
#do_transfer ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'app/controllers/kaui/bundles_controller.rb', line 55 def do_transfer key = params[:new_account_key] unless key.present? flash.now[:error] = 'No new account key given' render :action => :index and return end begin # Retrieve the new account to get the account id new_account = Kaui::Account::find_by_id_or_key(params[:new_account_key], false, false, ) rescue => e flash.now[:error] = "Error while retrieving new account: #{as_string(e)}" render :action => :index and return end begin billing_policy = params[:billing_policy] bundle = Kaui::Bundle::new(:bundle_id => params[:id], :account_id => new_account.account_id) bundle.transfer(nil, billing_policy, current_user.kb_username, params[:reason], params[:comment], ) redirect_to account_path(new_account.account_id), :notice => 'Bundle was successfully transferred' rescue => e flash.now[:error] = "Error while transferring bundle: #{as_string(e)}" render :action => :index end end |
#index ⇒ Object
3 4 |
# File 'app/controllers/kaui/bundles_controller.rb', line 3 def index end |
#pagination ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/controllers/kaui/bundles_controller.rb', line 6 def pagination search_key = params[:sSearch] offset = params[:iDisplayStart] || 0 limit = params[:iDisplayLength] || 10 bundles = Kaui::Bundle.list_or_search(search_key, offset, limit, ) json = { :sEcho => params[:sEcho], :iTotalRecords => bundles.pagination_max_nb_records, :iTotalDisplayRecords => bundles.pagination_total_nb_records, :aaData => [] } bundles.each do |bundle| json[:aaData] << [ view_context.link_to(view_context.truncate_uuid(bundle.bundle_id), view_context.url_for(:action => :show, :id => bundle.bundle_id)), view_context.link_to(view_context.truncate_uuid(bundle.account_id), view_context.url_for(:controller => :accounts, :action => :show, :id => bundle.account_id)), bundle.external_key, bundle.subscriptions.nil? ? '' : (bundle.subscriptions.map { |s| s.product_name }).join(', ') ] end respond_to do |format| format.json { render :json => json } end end |
#show ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/kaui/bundles_controller.rb', line 34 def show begin @bundle = Kaui::Bundle::find_by_id_or_key(params[:id], nil, ) @account = Kaui::Account::find_by_id(@bundle.account_id, false, false, ) @tags = @bundle.(false, 'NONE', ).sort { |tag_a, tag_b| tag_a <=> tag_b } rescue => e flash.now[:error] = "Error while retrieving bundle information: #{as_string(e)}" render :action => :index end end |
#transfer ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'app/controllers/kaui/bundles_controller.rb', line 45 def transfer begin @bundle = Kaui::Bundle::find_by_id_or_key(params[:id], nil, ) @account = Kaui::Account::find_by_id(@bundle.account_id, false, false, ) rescue => e flash.now[:error] = "Error while preparing to transfer bundle: #{as_string(e)}" render :action => :index end end |