Module: MnoEnterprise::Concerns::Controllers::ProvisionController
- Extended by:
- ActiveSupport::Concern
- Included in:
- ProvisionController
- Defined in:
- lib/mno_enterprise/concerns/controllers/provision_controller.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#create ⇒ Object
POST /provision TODO: check organization accessibility via ability.
-
#new ⇒ Object
Instance methods ================================================================== GET /provision/new?apps[]=vtiger&organization_id=1 TODO: check organization accessibility via ability.
Instance Method Details
#create ⇒ Object
POST /provision TODO: check organization accessibility via ability
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/mno_enterprise/concerns/controllers/provision_controller.rb', line 63 def create # Avoid double provisioning: previous url would be "/provision/new?apps[]=vtiger&organization_id=1" session.delete('previous_url') @organization = current_user.organizations.to_a.find { |o| o.id && o.id.to_s == params[:organization_id].to_s } :manage_app_instances, @organization app_instances = [] params[:apps].each do |product_name| app_instance = @organization.app_instances.create(product: product_name) app_instances << app_instance MnoEnterprise::EventLogger.info('app_add', current_user.id, 'App added', app_instance) end render json: app_instances.map(&:attributes).to_json, status: :created end |
#new ⇒ Object
Instance methods
GET /provision/new?apps[]=vtiger&organization_id=1 TODO: check organization accessibility via ability
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/mno_enterprise/concerns/controllers/provision_controller.rb', line 35 def new @apps = params[:apps] @organizations = current_user.organizations.to_a @organization = @organizations.find { |o| o.id && o.id.to_s == params[:organization_id].to_s } unless @organization @organization = @organizations.one? ? @organizations.first : nil end if @organization && cannot?(:manage_app_instances, @organization) msg = 'Unfortunately you do not have permission to purchase products for this organization' if @organizations.one? redirect_path = add_param_to_fragment(after_provision_path.to_s, 'flash', [{msg: msg, type: :error}.to_json]) redirect_to redirect_path else @organization = nil flash.now.alert = msg end end # Redirect to dashboard if no applications unless @apps && @apps.any? redirect_to after_provision_path end end |