From 10357237973d11c78181246fbc3831e6a53e2a9e Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 16 Apr 2012 16:35:10 +0200 Subject: [PATCH] Moved to generic event execution. --- app/controllers/application_controller.rb | 9 ++++++--- app/controllers/ticket_articles_controller.rb | 7 ------- app/controllers/tickets_controller.rb | 10 ---------- 3 files changed, 6 insertions(+), 20 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 5cfc6ef7a..84a46128d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -3,10 +3,8 @@ class ApplicationController < ActionController::Base # http_basic_authenticate_with :name => "test", :password => "ttt" helper_method :current_user, :authentication_check, :config_frontend, :user_data_full - before_filter :set_user, :cors_preflight_check - after_filter :set_access_control_headers - + after_filter :set_access_control_headers, :trigger_events # For all responses in this controller, return the CORS access control headers. def set_access_control_headers @@ -38,6 +36,11 @@ class ApplicationController < ActionController::Base private + # execute events + def trigger_events + Ticket::Observer::Notification.transaction + end + # Finds the User with the ID stored in the session with the key # :current_user_id This is a common way to handle user login in # a Rails application; logging in sets the session value and diff --git a/app/controllers/ticket_articles_controller.rb b/app/controllers/ticket_articles_controller.rb index 46f1f293a..68971c749 100644 --- a/app/controllers/ticket_articles_controller.rb +++ b/app/controllers/ticket_articles_controller.rb @@ -34,9 +34,6 @@ class TicketArticlesController < ApplicationController :o_id => @article.ticket_id ) - # execute ticket events - Ticket::Observer::Notification.transaction - render :json => @article, :status => :created else render :json => @article.errors, :status => :unprocessable_entity @@ -48,10 +45,6 @@ class TicketArticlesController < ApplicationController @article = Ticket::Article.find(params[:id]) if @article.update_attributes(params[:ticket_article]) - - # execute ticket events - Ticket::Observer::Notification.transaction - render :json => @article, :status => :ok else render :json => @article.errors, :status => :unprocessable_entity diff --git a/app/controllers/tickets_controller.rb b/app/controllers/tickets_controller.rb index 78dd598bd..717a4bede 100644 --- a/app/controllers/tickets_controller.rb +++ b/app/controllers/tickets_controller.rb @@ -55,9 +55,6 @@ class TicketsController < ApplicationController ) end - # execute ticket events - Ticket::Observer::Notification.transaction - render :json => @ticket, :status => :created end @@ -66,10 +63,6 @@ class TicketsController < ApplicationController @ticket = Ticket.find(params[:id]) if @ticket.update_attributes(params[:ticket]) - - # execute ticket events - Ticket::Observer::Notification.transaction - render :json => @ticket, :status => :ok else render :json => @ticket.errors, :status => :unprocessable_entity @@ -81,9 +74,6 @@ class TicketsController < ApplicationController @ticket = Ticket.find(params[:id]) @ticket.destroy - # execute ticket events - Ticket::Observer::Notification.transaction - head :ok end end