summaryrefslogtreecommitdiff
path: root/help/app/controllers
diff options
context:
space:
mode:
authorjessib <jessib@riseup.net>2012-11-07 15:45:09 -0800
committerjessib <jessib@riseup.net>2012-11-07 15:45:09 -0800
commit791a512247f657558b49677198c4e9abcb09645e (patch)
tree6740588d7829b7074097d027319b07b15c26697c /help/app/controllers
parent26d263ae1cf449d0f4e68b6d2b49b3c8e76c3461 (diff)
Improvements to flow for closing/re-opening tickets.
Diffstat (limited to 'help/app/controllers')
-rw-r--r--help/app/controllers/tickets_controller.rb25
1 files changed, 16 insertions, 9 deletions
diff --git a/help/app/controllers/tickets_controller.rb b/help/app/controllers/tickets_controller.rb
index ced9569..d66647f 100644
--- a/help/app/controllers/tickets_controller.rb
+++ b/help/app/controllers/tickets_controller.rb
@@ -39,24 +39,31 @@ class TicketsController < ApplicationController
def show
@ticket = Ticket.find(params[:id])
- redirect_to tickets_path, :alert => "No such ticket" if !@ticket
+ if !@ticket
+ redirect_to tickets_path, :alert => "No such ticket"
+ return
+ end
authorize_ticket_access
# @ticket.comments.build
# build ticket comments?
end
def update
-
@ticket = Ticket.find(params[:id])
if ticket_access?
- params[:ticket][:comments_attributes] = nil if params[:ticket][:comments_attributes].values.first[:body].blank? #unset comments hash if no new comment was typed
- @ticket.attributes = params[:ticket] #this will call comments_attributes=
-
- @ticket.is_open = false if params[:commit] == @reply_close_str #this overrides is_open selection
-
- # what if there is an update and no new comment? Confirm that there is a new comment to update posted_by:
- @ticket.comments.last.posted_by = (current_user ? current_user.id : nil) if @ticket.comments_changed? #protecting posted_by isn't working, so this should protect it.
+ if status = params[:change_status] #close or open button was pressed
+ @ticket.close if params[:change_status] == 'close'
+ @ticket.reopen if params[:change_status] == 'open'
+ else
+ params[:ticket][:comments_attributes] = nil if params[:ticket][:comments_attributes].values.first[:body].blank? #unset comments hash if no new comment was typed
+ @ticket.attributes = params[:ticket] #this will call comments_attributes=
+ #@ticket.is_open = false if params[:commit] == @reply_close_str #this overrides is_open selection
+ @ticket.close if params[:commit] == @reply_close_str #this overrides is_open selection
+
+ # what if there is an update and no new comment? Confirm that there is a new comment to update posted_by:
+ @ticket.comments.last.posted_by = (current_user ? current_user.id : nil) if @ticket.comments_changed? #protecting posted_by isn't working, so this should protect it.
+ end
if @ticket.changed? and @ticket.save
flash[:notice] = 'Ticket was successfully updated.'
respond_with @ticket