trabajo-afectivo/app/models/ticket/state.rb

56 lines
1.1 KiB
Ruby
Raw Normal View History

2014-02-03 19:23:00 +00:00
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
2015-04-27 21:27:51 +00:00
class Ticket
class State < ApplicationModel
belongs_to :state_type, class_name: 'Ticket::StateType'
validates :name, presence: true
2015-04-27 21:27:51 +00:00
latest_change_support
=begin
list tickets by customer
states = Ticket::State.by_category('open') # open|closed
returns:
state objects
=end
2015-04-27 21:27:51 +00:00
def self.by_category(category)
if category == 'open'
return Ticket::State.where(
state_type_id: Ticket::StateType.where( name: ['new', 'open', 'pending reminder', 'pending action'] )
)
elsif category == 'closed'
return Ticket::State.where(
state_type_id: Ticket::StateType.where( name: ['closed'] )
)
end
raise "Unknown category '#{category}'"
2014-02-03 19:23:00 +00:00
end
=begin
check if state is ignored for escalation
state = Ticket::State.lookup( :name => 'state name' )
result = state.ignore_escalation?
returns:
true/false
=end
2015-04-27 21:27:51 +00:00
def ignore_escalation?
ignore_escalation = ['removed', 'closed', 'merged']
return true if ignore_escalation.include?( self.name )
false
end
end
end