Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add internal attribute to service template #17781

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions app/models/service_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ class ServiceTemplate < ApplicationRecord
include NewWithTypeStiMixin
include TenancyMixin
include ArchivedMixin
include ReservedMixin
reserve_attribute :internal, :boolean
include_concern 'Filter'

belongs_to :tenant
Expand Down Expand Up @@ -70,6 +68,7 @@ class ServiceTemplate < ApplicationRecord
virtual_column :archived, :type => :boolean
virtual_column :active, :type => :boolean

default_value_for :internal, false
default_value_for :service_type, SERVICE_TYPE_ATOMIC
default_value_for(:generic_subtype) { |st| 'custom' if st.prov_type == 'generic' }

Expand All @@ -79,7 +78,7 @@ class ServiceTemplate < ApplicationRecord
scope :without_service_template_catalog_id, -> { where(:service_template_catalog_id => nil) }
scope :with_existent_service_template_catalog_id, -> { where.not(:service_template_catalog_id => nil) }
scope :displayed, -> { where(:display => true) }
scope :public_service_templates, -> { where.not(:id => Reserve.where(:resource_type => "ServiceTemplate").all.collect { |r| r.resource_id if r.reserved[:internal] }.compact) }
scope :public_service_templates, -> { where.not(:internal => true) }

def self.catalog_item_types
ci_types = Set.new(Rbac.filtered(ExtManagementSystem.all).flat_map(&:supported_catalog_types))
Expand Down