summaryrefslogtreecommitdiff
path: root/help/app/controllers/tickets_controller.rb
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2013-06-23 22:14:45 -0700
committerelijah <elijah@riseup.net>2013-06-23 22:14:45 -0700
commitfdf67344a80fcde0aab21c27d00412eeca609ca1 (patch)
tree4aef080bfabd06dc177ff5e1601f43268602b93f /help/app/controllers/tickets_controller.rb
parent9f8549fd485ee3dc9e63850a2af2a8859fdb70cc (diff)
fix several issues with tickets: js error, when to redirect, navigation, localization.
Diffstat (limited to 'help/app/controllers/tickets_controller.rb')
-rw-r--r--help/app/controllers/tickets_controller.rb30
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]