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

69 lines
1.7 KiB
Ruby
Raw Normal View History

2016-10-19 03:11:36 +00:00
# Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
class Ticket::State < ApplicationModel
belongs_to :state_type, class_name: 'Ticket::StateType'
belongs_to :next_state, class_name: 'Ticket::State'
validates :name, presence: true
latest_change_support
=begin
list tickets by customer
2015-09-08 07:49:15 +00:00
states = Ticket::State.by_category('open') # open|closed|work_on|work_on_all|pending_reminder|pending_action
returns:
state objects
=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'])
)
2015-09-06 23:54:47 +00:00
elsif category == 'pending_reminder'
return Ticket::State.where(
state_type_id: Ticket::StateType.where(name: ['pending reminder'])
2015-09-06 23:54:47 +00:00
)
2015-09-08 07:49:15 +00:00
elsif category == 'pending_action'
return Ticket::State.where(
state_type_id: Ticket::StateType.where(name: ['pending action'])
2015-09-08 07:49:15 +00:00
)
2015-09-06 23:54:47 +00:00
elsif category == 'work_on'
return Ticket::State.where(
state_type_id: Ticket::StateType.where(name: %w(new open))
2015-09-06 23:54:47 +00:00
)
elsif category == 'work_on_all'
return Ticket::State.where(
state_type_id: Ticket::StateType.where(name: ['new', 'open', 'pending reminder'])
)
elsif category == 'closed'
return Ticket::State.where(
state_type_id: Ticket::StateType.where(name: %w(closed))
)
2014-02-03 19:23:00 +00:00
end
2016-03-01 14:26:46 +00:00
raise "Unknown category '#{category}'"
end
=begin
check if state is ignored for escalation
state = Ticket::State.lookup(name: 'state name')
result = state.ignore_escalation?
returns:
true/false
=end
def ignore_escalation?
return true if ignore_escalation
false
end
end