Renamed ticket_state.ticket_state_type_id to ticket_state.state_type_id.

This commit is contained in:
Martin Edenhofer 2013-01-02 00:35:46 +01:00
parent 2d5bcf7f4a
commit 323e279ce5
6 changed files with 17 additions and 8 deletions

View file

@ -116,10 +116,10 @@ class TicketsController < ApplicationController
# get closed/open states
ticket_state_list_open = Ticket::State.where(
:ticket_state_type_id => Ticket::StateType.where( :name => ['new','open', 'pending reminder', 'pending action'] )
:state_type_id => Ticket::StateType.where( :name => ['new','open', 'pending reminder', 'pending action'] )
)
ticket_state_list_closed = Ticket::State.where(
:ticket_state_type_id => Ticket::StateType.where( :name => ['closed'] )
:state_type_id => Ticket::StateType.where( :name => ['closed'] )
)
# get tickets
@ -213,7 +213,7 @@ class TicketsController < ApplicationController
# get closed/open states
ticket_states = Ticket::State.where(
:ticket_state_type_id => Ticket::StateType.where( :name => ['new','open', 'pending reminder', 'pending action', 'closed'] )
:state_type_id => Ticket::StateType.where( :name => ['new','open', 'pending reminder', 'pending action', 'closed'] )
)
ticket = Ticket.find( params[:ticket_id] )
ticket_list = Ticket.where( :customer_id => ticket.customer_id, :ticket_state_id => ticket_states )

View file

@ -289,7 +289,7 @@ class Channel::EmailParser
# set ticket state to open if not new
if ticket
ticket_state = Ticket::State.find( ticket.ticket_state_id )
ticket_state_type = Ticket::StateType.find( ticket_state.ticket_state_type_id )
ticket_state_type = Ticket::StateType.find( ticket_state.state_type_id )
# if tickte is merged, find linked ticket
if ticket_state_type.name == 'merged'

View file

@ -21,7 +21,7 @@ class Observer::Ticket::CloseTime < ActiveRecord::Observer
# check if ticket is closed now
ticket_state = Ticket::State.lookup( :id => record.ticket_state_id )
ticket_state_type = Ticket::StateType.lookup( :id => ticket_state.ticket_state_type_id )
ticket_state_type = Ticket::StateType.lookup( :id => ticket_state.state_type_id )
return true if ticket_state_type.name != 'closed'
# set close_time

View file

@ -11,8 +11,8 @@ class Observer::Ticket::UserTicketCounter < ActiveRecord::Observer
def user_ticket_counter_update(record)
return if !record.customer_id
ticket_state_list_open = Ticket::State.where( :ticket_state_type_id => Ticket::StateType.where(:name => ['new','open', 'pending reminder', 'pending action']) )
ticket_state_list_closed = Ticket::State.where( :ticket_state_type_id => Ticket::StateType.where(:name => ['closed'] ) )
ticket_state_list_open = Ticket::State.where( :state_type_id => Ticket::StateType.where( :name => ['new','open', 'pending reminder', 'pending action']) )
ticket_state_list_closed = Ticket::State.where( :state_type_id => Ticket::StateType.where( :name => ['closed'] ) )
tickets_open = Ticket.where( :customer_id => record.customer_id, :ticket_state_id => ticket_state_list_open ).count()
tickets_closed = Ticket.where( :customer_id => record.customer_id, :ticket_state_id => ticket_state_list_closed ).count()

View file

@ -418,11 +418,12 @@ class Ticket < ApplicationModel
end
class StateType < ApplicationModel
has_many :states, :class_name => 'Ticket::State'
validates :name, :presence => true
end
class State < ApplicationModel
belongs_to :ticket_state_type, :class_name => 'Ticket::StateType'
belongs_to :state_type, :class_name => 'Ticket::StateType'
validates :name, :presence => true
end
end

View file

@ -0,0 +1,8 @@
class ChangeTicketState < ActiveRecord::Migration
def up
rename_column :ticket_states, :ticket_state_type_id, :state_type_id
end
def down
end
end