2013-06-12 15:59:58 +00:00
|
|
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2013-05-21 22:32:22 +00:00
|
|
|
class Ticket::State < ApplicationModel
|
|
|
|
belongs_to :state_type, :class_name => 'Ticket::StateType'
|
|
|
|
validates :name, :presence => true
|
2013-08-06 09:23:25 +00:00
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
list tickets by customer
|
|
|
|
|
|
|
|
states = Ticket::State.by_category('open') # open|closed
|
|
|
|
|
2013-08-06 09:49:56 +00:00
|
|
|
returns:
|
|
|
|
|
|
|
|
state objects
|
|
|
|
|
2013-08-06 09:23:25 +00:00
|
|
|
=end
|
|
|
|
|
|
|
|
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}'"
|
|
|
|
end
|
2013-08-06 09:49:56 +00:00
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
check if state is ignored for escalation
|
|
|
|
|
|
|
|
ticket_state = Ticket::State.lookup( :name => 'state name' )
|
|
|
|
|
|
|
|
result = ticket_state.ignore_escalation?
|
|
|
|
|
|
|
|
returns:
|
|
|
|
|
|
|
|
true/false
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def ignore_escalation?
|
|
|
|
ignore_escalation = ['removed', 'closed', 'merged']
|
|
|
|
return true if ignore_escalation.include?( self.name )
|
|
|
|
return false
|
|
|
|
end
|
2013-06-12 15:59:58 +00:00
|
|
|
end
|