Skip to content

Commit

Permalink
Merge pull request #17553 from AparnaKarve/fix_archived_api_attribute
Browse files Browse the repository at this point in the history
Fixed the virtual columns to be able to use in the API with `filter[]`
  • Loading branch information
agrare authored Jun 20, 2018
2 parents 84e9fa9 + fa60b22 commit 58af1d2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/models/mixins/archived_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ module ArchivedMixin
def archived?
!active?
end
alias_method :archived, :archived?

def active?
deleted_on.nil?
end
alias_method :active, :active?

def archive!
update_attributes!(:deleted_on => Time.now.utc)
Expand Down
3 changes: 2 additions & 1 deletion app/models/service_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ class ServiceTemplate < ApplicationRecord
virtual_column :type_display, :type => :string
virtual_column :template_valid, :type => :boolean
virtual_column :template_valid_error_message, :type => :string
virtual_column :archived?, :type => :boolean
virtual_column :archived, :type => :boolean
virtual_column :active, :type => :boolean

default_value_for :service_type, 'unknown'
default_value_for(:generic_subtype) { |st| 'custom' if st.prov_type == 'generic' }
Expand Down

0 comments on commit 58af1d2

Please sign in to comment.