Moved to generic event execution.
This commit is contained in:
parent
6d79f6caa0
commit
1035723797
3 changed files with 6 additions and 20 deletions
|
@ -3,10 +3,8 @@ class ApplicationController < ActionController::Base
|
||||||
# http_basic_authenticate_with :name => "test", :password => "ttt"
|
# http_basic_authenticate_with :name => "test", :password => "ttt"
|
||||||
|
|
||||||
helper_method :current_user, :authentication_check, :config_frontend, :user_data_full
|
helper_method :current_user, :authentication_check, :config_frontend, :user_data_full
|
||||||
|
|
||||||
before_filter :set_user, :cors_preflight_check
|
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.
|
# For all responses in this controller, return the CORS access control headers.
|
||||||
def set_access_control_headers
|
def set_access_control_headers
|
||||||
|
@ -38,6 +36,11 @@ class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
# execute events
|
||||||
|
def trigger_events
|
||||||
|
Ticket::Observer::Notification.transaction
|
||||||
|
end
|
||||||
|
|
||||||
# Finds the User with the ID stored in the session with the key
|
# 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
|
# :current_user_id This is a common way to handle user login in
|
||||||
# a Rails application; logging in sets the session value and
|
# a Rails application; logging in sets the session value and
|
||||||
|
|
|
@ -34,9 +34,6 @@ class TicketArticlesController < ApplicationController
|
||||||
:o_id => @article.ticket_id
|
:o_id => @article.ticket_id
|
||||||
)
|
)
|
||||||
|
|
||||||
# execute ticket events
|
|
||||||
Ticket::Observer::Notification.transaction
|
|
||||||
|
|
||||||
render :json => @article, :status => :created
|
render :json => @article, :status => :created
|
||||||
else
|
else
|
||||||
render :json => @article.errors, :status => :unprocessable_entity
|
render :json => @article.errors, :status => :unprocessable_entity
|
||||||
|
@ -48,10 +45,6 @@ class TicketArticlesController < ApplicationController
|
||||||
@article = Ticket::Article.find(params[:id])
|
@article = Ticket::Article.find(params[:id])
|
||||||
|
|
||||||
if @article.update_attributes(params[:ticket_article])
|
if @article.update_attributes(params[:ticket_article])
|
||||||
|
|
||||||
# execute ticket events
|
|
||||||
Ticket::Observer::Notification.transaction
|
|
||||||
|
|
||||||
render :json => @article, :status => :ok
|
render :json => @article, :status => :ok
|
||||||
else
|
else
|
||||||
render :json => @article.errors, :status => :unprocessable_entity
|
render :json => @article.errors, :status => :unprocessable_entity
|
||||||
|
|
|
@ -55,9 +55,6 @@ class TicketsController < ApplicationController
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
# execute ticket events
|
|
||||||
Ticket::Observer::Notification.transaction
|
|
||||||
|
|
||||||
render :json => @ticket, :status => :created
|
render :json => @ticket, :status => :created
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -66,10 +63,6 @@ class TicketsController < ApplicationController
|
||||||
@ticket = Ticket.find(params[:id])
|
@ticket = Ticket.find(params[:id])
|
||||||
|
|
||||||
if @ticket.update_attributes(params[:ticket])
|
if @ticket.update_attributes(params[:ticket])
|
||||||
|
|
||||||
# execute ticket events
|
|
||||||
Ticket::Observer::Notification.transaction
|
|
||||||
|
|
||||||
render :json => @ticket, :status => :ok
|
render :json => @ticket, :status => :ok
|
||||||
else
|
else
|
||||||
render :json => @ticket.errors, :status => :unprocessable_entity
|
render :json => @ticket.errors, :status => :unprocessable_entity
|
||||||
|
@ -81,9 +74,6 @@ class TicketsController < ApplicationController
|
||||||
@ticket = Ticket.find(params[:id])
|
@ticket = Ticket.find(params[:id])
|
||||||
@ticket.destroy
|
@ticket.destroy
|
||||||
|
|
||||||
# execute ticket events
|
|
||||||
Ticket::Observer::Notification.transaction
|
|
||||||
|
|
||||||
head :ok
|
head :ok
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue