Moved to new history API.
This commit is contained in:
parent
b82a262de9
commit
6de87eb1bf
3 changed files with 37 additions and 8 deletions
|
@ -156,12 +156,40 @@ class TicketsController < ApplicationController
|
||||||
users[ ticket.owner_id ] = User.user_data_full( ticket.owner_id )
|
users[ ticket.owner_id ] = User.user_data_full( ticket.owner_id )
|
||||||
users[ ticket.customer_id ] = User.user_data_full( ticket.customer_id )
|
users[ ticket.customer_id ] = User.user_data_full( ticket.customer_id )
|
||||||
history.each do |item|
|
history.each do |item|
|
||||||
users[ item['created_by_id'] ] = User.user_data_full( item['created_by_id'] )
|
|
||||||
|
users[ item[:created_by_id] ] = User.user_data_full( item[:created_by_id] )
|
||||||
|
item_tmp = item.attributes
|
||||||
if item['history_object'] == 'Ticket::Article'
|
if item['history_object'] == 'Ticket::Article'
|
||||||
item['type'] = 'Article ' + item['type'].to_s
|
item_temp['type'] = 'Article ' + item['type'].to_s
|
||||||
else
|
else
|
||||||
item['type'] = 'Ticket ' + item['type'].to_s
|
item_tmp['type'] = 'Ticket ' + item['type'].to_s
|
||||||
end
|
end
|
||||||
|
item_tmp['history_type'] = item.history_type.name
|
||||||
|
item_tmp['history_object'] = item.history_object.name
|
||||||
|
if item.history_attribute
|
||||||
|
item_tmp['history_attribute'] = item.history_attribute.name
|
||||||
|
end
|
||||||
|
item_tmp.delete( 'history_attribute_id' )
|
||||||
|
item_tmp.delete( 'history_object_id' )
|
||||||
|
item_tmp.delete( 'history_type_id' )
|
||||||
|
item_tmp.delete( 'o_id' )
|
||||||
|
item_tmp.delete( 'updated_at' )
|
||||||
|
if item_tmp['id_to'] == nil && item_tmp['id_from'] == nil
|
||||||
|
item_tmp.delete( 'id_to' )
|
||||||
|
item_tmp.delete( 'id_from' )
|
||||||
|
end
|
||||||
|
if item_tmp['value_to'] == nil && item_tmp['value_from'] == nil
|
||||||
|
item_tmp.delete( 'value_to' )
|
||||||
|
item_tmp.delete( 'value_from' )
|
||||||
|
end
|
||||||
|
if item_tmp['related_history_object_id'] == nil
|
||||||
|
item_tmp.delete( 'related_history_object_id' )
|
||||||
|
end
|
||||||
|
if item_tmp['related_o_id'] == nil
|
||||||
|
item_tmp.delete( 'related_o_id' )
|
||||||
|
end
|
||||||
|
history_list.push item_tmp
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# fetch meta relations
|
# fetch meta relations
|
||||||
|
@ -173,7 +201,7 @@ class TicketsController < ApplicationController
|
||||||
render :json => {
|
render :json => {
|
||||||
:ticket => ticket,
|
:ticket => ticket,
|
||||||
:users => users,
|
:users => users,
|
||||||
:history => history,
|
:history => history_list,
|
||||||
:history_objects => history_objects,
|
:history_objects => history_objects,
|
||||||
:history_types => history_types,
|
:history_types => history_types,
|
||||||
:history_attributes => history_attributes
|
:history_attributes => history_attributes
|
||||||
|
|
|
@ -65,6 +65,7 @@ class Observer::Ticket::Article::CommunicateEmail < ActiveRecord::Observer
|
||||||
:related_history_object => 'Ticket',
|
:related_history_object => 'Ticket',
|
||||||
:value_from => record.subject,
|
:value_from => record.subject,
|
||||||
:value_to => recipient_list,
|
:value_to => recipient_list,
|
||||||
|
:created_by_id => record.created_by_id,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -588,7 +588,7 @@ class TicketTest < ActiveSupport::TestCase
|
||||||
assert( ticket, 'ticket created' )
|
assert( ticket, 'ticket created' )
|
||||||
|
|
||||||
# set ticket at 10:00 to pending
|
# set ticket at 10:00 to pending
|
||||||
History.history_create(
|
History.add(
|
||||||
:history_type => 'updated',
|
:history_type => 'updated',
|
||||||
:history_object => 'Ticket',
|
:history_object => 'Ticket',
|
||||||
:history_attribute => 'ticket_state',
|
:history_attribute => 'ticket_state',
|
||||||
|
@ -603,7 +603,7 @@ class TicketTest < ActiveSupport::TestCase
|
||||||
)
|
)
|
||||||
|
|
||||||
# set ticket at 10:30 to open
|
# set ticket at 10:30 to open
|
||||||
History.history_create(
|
History.add(
|
||||||
:history_type => 'updated',
|
:history_type => 'updated',
|
||||||
:history_object => 'Ticket',
|
:history_object => 'Ticket',
|
||||||
:history_attribute => 'ticket_state',
|
:history_attribute => 'ticket_state',
|
||||||
|
@ -618,7 +618,7 @@ class TicketTest < ActiveSupport::TestCase
|
||||||
)
|
)
|
||||||
|
|
||||||
# set ticket from 11:00 to pending
|
# set ticket from 11:00 to pending
|
||||||
#History.history_create(
|
#History.add(
|
||||||
# :history_type => 'updated',
|
# :history_type => 'updated',
|
||||||
# :history_object => 'Ticket',
|
# :history_object => 'Ticket',
|
||||||
# :history_attribute => 'ticket_state',
|
# :history_attribute => 'ticket_state',
|
||||||
|
@ -642,7 +642,7 @@ class TicketTest < ActiveSupport::TestCase
|
||||||
)
|
)
|
||||||
|
|
||||||
# set ticket from 11:30 to closed
|
# set ticket from 11:30 to closed
|
||||||
History.history_create(
|
History.add(
|
||||||
:history_type => 'updated',
|
:history_type => 'updated',
|
||||||
:history_object => 'Ticket',
|
:history_object => 'Ticket',
|
||||||
:history_attribute => 'ticket_state',
|
:history_attribute => 'ticket_state',
|
||||||
|
|
Loading…
Reference in a new issue