From 28edddec90ea67b4b204b0a6d86823f11f180b61 Mon Sep 17 00:00:00 2001 From: MAhsenArif Date: Thu, 1 Feb 2018 20:37:35 +0500 Subject: [PATCH] [MNOE-406] Added logic to load delisted apps if already in dashboard --- .../jpi/v1/app_instances/_resource.json.jbuilder | 1 + core/lib/mno_enterprise/concerns/models/app_instance.rb | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/api/app/views/mno_enterprise/jpi/v1/app_instances/_resource.json.jbuilder b/api/app/views/mno_enterprise/jpi/v1/app_instances/_resource.json.jbuilder index e09476215..3d37ec774 100644 --- a/api/app/views/mno_enterprise/jpi/v1/app_instances/_resource.json.jbuilder +++ b/api/app/views/mno_enterprise/jpi/v1/app_instances/_resource.json.jbuilder @@ -23,6 +23,7 @@ end # json.connector_version app_instance.oauth_keys[:version] # end +app_instance.without_tenant = true if params[:data] && params[:data] == 'unscoped' app_instance.app.tap do |a| json.app_id a.id json.app_name a.name diff --git a/core/lib/mno_enterprise/concerns/models/app_instance.rb b/core/lib/mno_enterprise/concerns/models/app_instance.rb index 9c7811baa..2b1e2ceac 100644 --- a/core/lib/mno_enterprise/concerns/models/app_instance.rb +++ b/core/lib/mno_enterprise/concerns/models/app_instance.rb @@ -42,6 +42,8 @@ module MnoEnterprise::Concerns::Models::AppInstance :owner_type, :terminated_at, :stopped_at, :billing_type, :autostop_at, :autostop_interval, :next_status, :soa_enabled, :oauth_company, :oauth_keys, :oauth_keys_valid, :free_trial_end_at, :per_user_licence, :active_licences_count + attr_accessor :without_tenant + #============================================================== # Constants #============================================================== @@ -52,7 +54,6 @@ module MnoEnterprise::Concerns::Models::AppInstance # Associations #============================================================== belongs_to :owner, class_name: 'MnoEnterprise::Organization' - belongs_to :app, class_name: 'MnoEnterprise::App' # Define connector_stack?, cloud_stack? etc. methods [:cube, :cloud, :connector].each do |stackname| @@ -62,6 +63,10 @@ module MnoEnterprise::Concerns::Models::AppInstance end scope :active, -> { where('status.in' => ACTIVE_STATUSES) } + + def app + MnoEnterprise::App.find(self.app_id, { unscoped: self.without_tenant }) + end end #==================================================================