Fixed ticket reload on server change. Moved to extra notify_clients_support method on models.

This commit is contained in:
Martin Edenhofer 2015-02-01 13:08:11 +01:00
parent 392dd59dc4
commit 7810ead783
9 changed files with 48 additions and 40 deletions

View file

@ -14,6 +14,7 @@ class ApplicationModel < ActiveRecord::Base
after_create :cache_delete
after_update :cache_delete
after_touch :cache_delete
after_destroy :cache_delete
after_create :attachments_buffer_check
@ -418,6 +419,23 @@ returns
=begin
activate client notify support on create, update, touch and destroy
class Model < ApplicationModel
notify_clients_support
end
=end
def self.notify_clients_support
after_create :notify_clients_after_create
after_update :notify_clients_after_update
after_touch :notify_clients_after_update
after_destroy :notify_clients_after_destroy
end
=begin
notify_clients_after_create after model got created
used as callback in model file

View file

@ -9,9 +9,7 @@ class Job < ApplicationModel
before_create :updated_matching
before_update :updated_matching
after_create :notify_clients_after_create
after_update :notify_clients_after_update
after_destroy :notify_clients_after_destroy
notify_clients_support
def self.run
time = Time.new
@ -27,12 +25,12 @@ class Job < ApplicationModel
jobs = Job.where( :active => true )
jobs.each do |job|
# only execute jobs, older then 2 min, to give admin posibility to change
next if job.updated_at > Time.now - 2.minutes
# only execute jobs, older then 1 min, to give admin posibility to change
next if job.updated_at > Time.now - 1.minutes
# check if jobs need to be executed
# ignore if job was running within last 10 min.
next if job.last_run_at > Time.now - 10.minutes
next if job.last_run_at && job.last_run_at > Time.now - 10.minutes
# check day
next if !job.timeplan['days'].include?( day_map[time.wday] )

View file

@ -11,11 +11,9 @@ class Organization < ApplicationModel
has_many :members, :class_name => 'User'
validates :name, :presence => true
after_create :notify_clients_after_create
after_update :notify_clients_after_update
activity_stream_support :role => 'Admin'
history_support
search_index_support
notify_clients_support
end

View file

@ -3,7 +3,5 @@
class Template < ApplicationModel
store :options
validates :name, :presence => true
after_create :notify_clients_after_create
after_update :notify_clients_after_update
after_destroy :notify_clients_after_destroy
notify_clients_support
end

View file

@ -3,7 +3,5 @@
class TextModule < ApplicationModel
validates :name, :presence => true
validates :content, :presence => true
after_create :notify_clients_after_create
after_update :notify_clients_after_update
after_destroy :notify_clients_after_destroy
notify_clients_support
end

View file

@ -17,9 +17,8 @@ class Ticket < ApplicationModel
before_create :check_generate, :check_defaults, :check_title
before_update :check_defaults, :check_title
before_destroy :destroy_dependencies
after_create :notify_clients_after_create
after_update :notify_clients_after_update
after_destroy :notify_clients_after_destroy
notify_clients_support
activity_stream_support :ignore_attributes => {
:create_article_type_id => true,

View file

@ -15,9 +15,7 @@ class Ticket::Article < ApplicationModel
belongs_to :updated_by, :class_name => 'User'
before_create :check_subject
before_update :check_subject
after_create :notify_clients_after_create
after_update :notify_clients_after_update
after_destroy :notify_clients_after_destroy
notify_clients_support
activity_stream_support :ignore_attributes => {
:type_id => true,

View file

@ -32,9 +32,10 @@ class User < ApplicationModel
before_create :check_name, :check_email, :check_login, :check_password
before_update :check_password, :check_email, :check_login
after_create :avatar_check, :notify_clients_after_create
after_update :avatar_check, :notify_clients_after_update
after_destroy :avatar_destroy, :notify_clients_after_destroy
after_create :avatar_check
after_update :avatar_check
after_destroy :avatar_destroy
notify_clients_support
has_and_belongs_to_many :groups, :after_add => :cache_update, :after_remove => :cache_update
has_and_belongs_to_many :roles, :after_add => :cache_update, :after_remove => :cache_update

View file

@ -16,14 +16,14 @@ class AgentTicketActionLevel1Test < TestCase
:execute => 'create_ticket',
:group => 'Users',
:subject => 'some subject 123äöü',
:body => 'some body 123äöü',
:body => 'some body 123äöü - with closed tab',
},
# check ticket
{
:execute => 'match',
:css => '.content.active .ticket-article',
:value => 'some body 123äöü',
:value => 'some body 123äöü - with closed tab',
:match_result => true,
},
@ -44,7 +44,7 @@ class AgentTicketActionLevel1Test < TestCase
#},
{
:execute => 'set_ticket_attributes',
:body => 'some body 1234 äöüß',
:body => 'some body 1234 äöüß - with closed tab',
},
{
:execute => 'click',
@ -57,7 +57,7 @@ class AgentTicketActionLevel1Test < TestCase
{
:execute => 'watch_for',
:area => '.content.active .ticket-article',
:value => 'some body 1234 äöüß',
:value => 'some body 1234 äöüß - with closed tab',
},
{
:execute => 'close_all_tasks',
@ -74,14 +74,14 @@ class AgentTicketActionLevel1Test < TestCase
:execute => 'create_ticket',
:group => 'Users',
:subject => 'test to merge',
:body => 'some body 123äöü 222 - test to merge',
:body => 'some body 123äöü 222 - test to merge - with closed tab',
},
# check ticket
{
:execute => 'watch_for',
:area => '.content.active .ticket-article',
:value => 'some body 123äöü 222 - test to merge',
:value => 'some body 123äöü 222 - test to merge - with closed tab',
},
# update ticket
@ -92,7 +92,7 @@ class AgentTicketActionLevel1Test < TestCase
#},
{
:execute => 'set_ticket_attributes',
:body => 'some body 1234 äöüß 333',
:body => 'some body 1234 äöüß 333 - with closed tab',
},
{
:execute => 'click',
@ -105,7 +105,7 @@ class AgentTicketActionLevel1Test < TestCase
{
:execute => 'watch_for',
:area => '.content.active .ticket-article',
:value => 'some body 1234 äöüß 333',
:value => 'some body 1234 äöüß 333 - with closed tab',
},
# check if task is shown
@ -158,7 +158,7 @@ class AgentTicketActionLevel1Test < TestCase
{
:execute => 'match',
:css => 'body',
:value => 'test to merge',
:value => 'test to merge - with closed tab',
:match_result => true,
},
@ -186,14 +186,14 @@ class AgentTicketActionLevel1Test < TestCase
:execute => 'create_ticket',
:group => 'Users',
:subject => 'some subject 123äöü',
:body => 'some body 123äöü',
:body => 'some body 123äöü - with open tab',
},
# check ticket
{
:execute => 'match',
:css => '.content.active .ticket-article',
:value => 'some body 123äöü',
:value => 'some body 123äöü - with open tab',
:match_result => true,
},
@ -218,14 +218,14 @@ class AgentTicketActionLevel1Test < TestCase
:execute => 'create_ticket',
:group => 'Users',
:subject => 'test to merge',
:body => 'some body 123äöü 222 - test to merge',
:body => 'some body 123äöü 222 - test to merge - with open tab',
},
# check ticket
{
:execute => 'watch_for',
:area => '.content.active .ticket-article',
:value => 'some body 123äöü 222 - test to merge',
:value => 'some body 123äöü 222 - test to merge - with open tab',
},
# check if task is shown
@ -278,7 +278,7 @@ class AgentTicketActionLevel1Test < TestCase
{
:execute => 'match',
:css => 'body',
:value => 'test to merge',
:value => 'test to merge - with open tab',
:match_result => true,
},