diff options
author | elijah <elijah@riseup.net> | 2013-06-23 22:14:45 -0700 |
---|---|---|
committer | elijah <elijah@riseup.net> | 2013-07-04 04:04:54 -0700 |
commit | d121373b7c21a29e47708e8b67aeb964202e52c5 (patch) | |
tree | 92ea7dda1a3c7173785f19f0844cd637984f2924 /help/app/controllers | |
parent | 38544a07de7988eee91343c1491dae1e08ce5034 (diff) |
fix several issues with tickets: js error, when to redirect, navigation, localization.
Diffstat (limited to 'help/app/controllers')
-rw-r--r-- | help/app/controllers/tickets_controller.rb | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/help/app/controllers/tickets_controller.rb b/help/app/controllers/tickets_controller.rb index d478da9..3be7d10 100644 --- a/help/app/controllers/tickets_controller.rb +++ b/help/app/controllers/tickets_controller.rb @@ -42,19 +42,18 @@ class TicketsController < ApplicationController if params[:commit] == t(:close) @ticket.is_open = false @ticket.save - redirect_to tickets_path + redirect_to_tickets elsif params[:commit] == t(:open) @ticket.is_open = true @ticket.save redirect_to @ticket + elsif params[:commit] == t(:cancel) + redirect_to_tickets else @ticket.attributes = cleanup_ticket_params(params[:ticket]) if params[:commit] == t(:reply_and_close) @ticket.close - should_redirect = true - else - should_redirect = !logged_in? end if @ticket.comments_changed? @@ -64,11 +63,7 @@ class TicketsController < ApplicationController if @ticket.changed? if @ticket.save flash[:notice] = t(:changes_saved) - if should_redirect - redirect_to tickets_path - else - redirect_to @ticket - end + redirect_to_tickets else respond_with @ticket end @@ -97,6 +92,23 @@ class TicketsController < ApplicationController private + # + # redirects to ticket index, if appropriate. + # otherwise, just redirects to @ticket + # + def redirect_to_tickets + if logged_in? + if params[:commit] == t(:reply_and_close) + redirect_to tickets_url + else + redirect_to @ticket + end + else + # if we are not logged in, there is no index to view + redirect_to @ticket + end + end + # unset comments hash if no new comment was typed def cleanup_ticket_params(ticket) if ticket && ticket[:comments_attributes] |