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
Methods included from ErrorHelper
Instance Method Details
#do_transfer ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 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 |
# File 'app/controllers/kaui/bundles_controller.rb', line 44 def do_transfer bundle_id = params[:id] key = params[:new_account_key] if key.present? begin result = Kaui::KillbillHelper.get_account_by_key(key) rescue => e flash[:error] = "Error while retrieving account for #{key}: #{as_string(e)}" render :action => :index return end if bundle_id.present? && result.is_a?(Kaui::Account) @new_account = result begin Kaui::KillbillHelper::transfer_bundle(bundle_id, @new_account.account_id) flash[:info] = "Bundle transfered successfully" rescue => e flash[:error] = "Error transfering bundle #{as_string(e)}" end redirect_to Kaui.account_home_path.call(@new_account.external_key) return else flash[:error] = "Could not retrieve account #{result}" end else flash[:error] = "No account key given" end begin @bundle = Kaui::KillbillHelper::get_bundle(bundle_id) @account = Kaui::KillbillHelper::get_account_by_bundle_id(bundle_id) rescue => e flash[:error] = "Error while redirecting: #{as_string(e)}" render :transfer end end |
#index ⇒ Object
3 4 5 6 7 |
# File 'app/controllers/kaui/bundles_controller.rb', line 3 def index if params[:bundle_id].present? redirect_to kaui_engine.bundle_path(params[:bundle_id]) end end |
#show ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/kaui/bundles_controller.rb', line 9 def show key = params[:id] if key.present? begin @bundle = Kaui::KillbillHelper::get_bundle_by_key(key, params[:account_id]) if @bundle.present? @account = Kaui::KillbillHelper::get_account_by_bundle_id(@bundle.bundle_id) @subscriptions = Kaui::KillbillHelper::get_subscriptions_for_bundle(@bundle.bundle_id) @overdue_state = Kaui::KillbillHelper::get_overdue_state_for_bundle(@bundle.bundle_id) else flash[:error] = "Bundle #{key} not found" render :action => :index end rescue => e flash[:error] = "Error while retrieving bundle information for #{key}: #{as_string(e)}" end else flash[:error] = "No id given" end end |
#transfer ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/kaui/bundles_controller.rb', line 31 def transfer bundle_id = params[:id] begin @bundle = Kaui::KillbillHelper::get_bundle(bundle_id) @account = Kaui::KillbillHelper::get_account_by_bundle_id(bundle_id) rescue => e flash[:error] = "Error while preparing to transfer bundle: #{as_string(e)}" end if @account.nil? flash[:error] = "Account not found for bundle id #{bundle_id}" end end |