summaryrefslogtreecommitdiff
path: root/engines/support/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'engines/support/app/controllers')
-rw-r--r--engines/support/app/controllers/tickets_controller.rb66
1 files changed, 30 insertions, 36 deletions
diff --git a/engines/support/app/controllers/tickets_controller.rb b/engines/support/app/controllers/tickets_controller.rb
index 19663c3..bb98277 100644
--- a/engines/support/app/controllers/tickets_controller.rb
+++ b/engines/support/app/controllers/tickets_controller.rb
@@ -5,8 +5,8 @@ class TicketsController < ApplicationController
#has_scope :open, :type => boolean
before_filter :require_login, :only => [:index]
- before_filter :fetch_ticket, :only => [:show, :update, :destroy]
- before_filter :require_ticket_access, :only => [:show, :update, :destroy]
+ before_filter :fetch_ticket, except: [:new, :create, :index]
+ before_filter :require_ticket_access, except: [:new, :create, :index]
before_filter :fetch_user
before_filter :set_title
@@ -37,33 +37,32 @@ class TicketsController < ApplicationController
end
end
- def update
- if params[:button] == 'close'
- @ticket.is_open = false
- @ticket.save
- redirect_to_tickets
- elsif params[:button] == 'open'
- @ticket.is_open = true
- @ticket.save
- redirect_to auto_ticket_path(@ticket)
- else
- @ticket.attributes = cleanup_ticket_params(params[:ticket])
+ def close
+ @ticket.close
+ @ticket.save
+ redirect_to redirection_path
+ end
- if params[:button] == 'reply_and_close'
- @ticket.close
- end
+ def open
+ @ticket.reopen
+ @ticket.save
+ redirect_to redirection_path
+ end
- if @ticket.comments_changed?
- @ticket.comments.last.posted_by = current_user.id
- @ticket.comments.last.private = false unless admin?
- end
+ def update
+ @ticket.attributes = cleanup_ticket_params(params[:ticket])
- if @ticket.changed? and @ticket.save
- redirect_to_tickets
- else
- redirect_to auto_ticket_path(@ticket)
- end
+ if params[:button] == 'reply_and_close'
+ @ticket.close
+ end
+
+ if @ticket.comments_changed?
+ @ticket.comments.last.posted_by = current_user.id
+ @ticket.comments.last.private = false unless admin?
end
+
+ @ticket.save
+ respond_with @ticket, location: redirection_path
end
def index
@@ -90,19 +89,14 @@ class TicketsController < ApplicationController
private
#
- # redirects to ticket index, if appropriate.
- # otherwise, just redirects to @ticket
+ # ticket index, if appropriate.
+ # otherwise, just @ticket
#
- def redirect_to_tickets
- if logged_in?
- if params[:button] == t(:reply_and_close)
- redirect_to auto_tickets_path
- else
- redirect_to auto_ticket_path(@ticket)
- end
+ def redirection_path
+ if logged_in? && params[:button] == t(:reply_and_close)
+ auto_tickets_path
else
- # if we are not logged in, there is no index to view
- redirect_to auto_ticket_path(@ticket)
+ auto_ticket_path(@ticket)
end
end