Skip to content

Commit

Permalink
Fix post-action routing to work the same everywhere.
Browse files Browse the repository at this point in the history
  • Loading branch information
djcp committed Apr 28, 2010
1 parent 6b1f57e commit 5561410
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
10 changes: 5 additions & 5 deletions app/controllers/admin/bulk_action_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def bulk_note
flash[:error] = "There was an error creating some notes: #{exc.message}"
end
end
redirect_to params[:return_to] and return
manage_destination
end

def bulk_tag_remove
Expand All @@ -30,7 +30,7 @@ def bulk_tag_remove
Contact.bulk_index(contact_ids)
flash[:notice] = 'Those tags have been removed.'
end
redirect_to params[:return_to] and return
manage_destination
end

def bulk_contact_delete
Expand All @@ -45,7 +45,7 @@ def bulk_contact_delete
end
flash[:notice] = 'Those contacts have been permanently deleted.'
end
redirect_to params[:return_to] and return
manage_destination
end

def bulk_tag
Expand All @@ -61,7 +61,7 @@ def bulk_tag
Contact.bulk_index(contact_ids)
flash[:notice] = 'Those contacts have been tagged.'
end
redirect_to params[:return_to] and return
manage_destination
end

# Add selected contacts to a user's active campaign or create a new one with selected contacts.
Expand All @@ -86,7 +86,7 @@ def bulk_create_campaign
flash[:error] = "We couldn't create the campaign. Perhaps a more unique title?"
end
end
redirect_to params[:return_to] and return
manage_destination
end

protected
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ApplicationController < ActionController::Base
# from your application log (in this case, all fields with names like "password").
filter_parameter_logging :password, :passwd

def manage_destination(default_url_hash)
def manage_destination(default_url_hash = {})
if params[:_redirect_to]
redirect_to params[:_redirect_to] and return
elsif ! default_url_hash.blank?
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/contact_carts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def create
flash[:error] = "We couldn't create the cart."
end
end
redirect_to params[:return_to] and return
manage_destination
end

# (POST) remove_contact removes the contact with id of <tt>params[:contact_to_remove_id]</tt> from the user's active contact cart
Expand All @@ -72,7 +72,7 @@ def remove_contact
@contact_cart = @session_user.active_contact_cart
@contact_cart.contacts.delete( Contact.find(params[:contact_to_remove_id]))
@contact_cart.save
redirect_to params[:return_to] and return
manage_destination
end
end

Expand All @@ -86,7 +86,7 @@ def destroy
flash[:error] = 'Contact cart not destroyed. Are you trying to delete someone else\'s cart?'
end
respond_to do |format|
format.html { redirect_to(params[:return_to] || contact_carts_url) }
format.html { manage_destination }
format.xml { head :ok }
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/contact_carts/_bulk_action.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<%= text_field_tag 'title', "#{@session_user.username}'s cart - #{Date.today}" %>
<br/>
<% end %>
<%= hidden_field_tag 'return_to', url_for(sanitized_url_params) %>
<%= hidden_field_tag '_redirect_to', url_for(sanitized_url_params) %>
<% if cart.nil? || (cart && @session_user == cart.user) %>
<%= submit_tag 'Add Selected Contacts to Cart' %>
<br/>
Expand Down
4 changes: 2 additions & 2 deletions app/views/contact_carts/_contacts.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<% if @session_user == cart.user %>
<% form_tag(contact_cart_remove_contact_path(cart), :class => 'contact-cart-remove-contact') do %>
<%= hidden_field_tag 'contact_to_remove_id', contact.id %>
<%= hidden_field_tag 'return_to', url_for(sanitized_url_params) %>
<%= icon_submit_tag(:vcard_delete, "Remove", :class => 'contact-cart-remove-submit') %>
<%= hidden_field_tag '_redirect_to', url_for(sanitized_url_params) %>
<%= icon_submit_tag(:vcard_delete, "Remove", :class => 'contact-cart-remove-submit', :title => 'delete this contact from the cart') %>
<% end %>
<% end %>
</li>
Expand Down
10 changes: 5 additions & 5 deletions app/views/shared/_bulk_contact_actions.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div id="flyout-apply-bulk-tags-actions" class="toggle-target tags sub-action" style="display: none;">
<p>Apply tags to checked contacts.</p>
<% form_tag(url_for(:controller => '/admin/bulk_action', :action => :bulk_tag), :id => 'apply-tags-form') do %>
<%= hidden_field_tag 'return_to', url_for(sanitized_url_params) %>
<%= hidden_field_tag '_redirect_to', url_for(sanitized_url_params) %>
<%= text_field_tag 'bulk_apply_tags' %>
<%= submit_tag 'Apply Tags' %><br/>
<% end %>
Expand All @@ -22,7 +22,7 @@
<div id="flyout-remove-bulk-tags-actions" class="toggle-target tags sub-action" style="display: none;">
<p>Remove tags from the checked contacts.</p>
<% form_tag(url_for(:controller => '/admin/bulk_action', :action => :bulk_tag_remove), :id => 'remove-tags-form') do %>
<%= hidden_field_tag 'return_to', url_for(sanitized_url_params) %>
<%= hidden_field_tag '_redirect_to', url_for(sanitized_url_params) %>
<%= text_field_tag 'bulk_remove_tags' %><%= submit_tag 'Remove tags' %><br/>
<% end %>
<script type="text/javascript" language="javascript">
Expand All @@ -37,7 +37,7 @@
<div id="flyout-bulk-note-actions" class="toggle-target tags sub-action" style="display: none;">
<p>Add a note to the checked contacts.</p>
<% form_tag(url_for(:controller => '/admin/bulk_action', :action => :bulk_note), :id => 'bulk-note') do %>
<%= hidden_field_tag 'return_to', url_for(sanitized_url_params) %>
<%= hidden_field_tag '_redirect_to', url_for(sanitized_url_params) %>
<p class="field"><label for="note">Note:</label><br/>
<%= text_area_tag 'note', '', :size => '35x5' %><br />
Due Date: <%= calendar_date_select_tag "follow_up", '', :time => true, :minute_interval => 15 %><br />
Expand All @@ -50,7 +50,7 @@ Due Date: <%= calendar_date_select_tag "follow_up", '', :time => true, :minute_i
<h4 id="flyout-bulk-contact-delete" class="toggle hidden tags sub-action"><%= icon(:user) %> Delete checked contacts</h4>
<div id="flyout-bulk-contact-delete-actions" class="toggle-target tags sub-action" style="display: none;">
<% form_tag(url_for(:controller => '/admin/bulk_action', :action => :bulk_contact_delete), :id => 'bulk-delete-contacts') do %>
<%= hidden_field_tag 'return_to', url_for(sanitized_url_params) %>
<%= hidden_field_tag '_redirect_to', url_for(sanitized_url_params) %>
<%= submit_tag 'Delete checked contacts.' %><br/>
<% end %>
</div>
Expand All @@ -62,7 +62,7 @@ Due Date: <%= calendar_date_select_tag "follow_up", '', :time => true, :minute_i
<label for="title">Title:</label> <%= text_field_tag 'title',"#{@session_user.username} - #{Date.today}" %>
<br/>
<% end %>
<%= hidden_field_tag 'return_to', url_for(sanitized_url_params) %>
<%= hidden_field_tag '_redirect_to', url_for(sanitized_url_params) %>
<%= submit_tag 'Add Cart and Selected Contacts to Mail Campaign' %><br/>
<% if !@session_user.active_campaign.nil? %>
<%= link_to show_icon_with_text(:email_delete, 'Delete my Active Mail Campaign'), @session_user.active_campaign, :confirm => "Are you sure you want to delete \"#{@session_user.active_campaign.title}\"?", :method => :delete %>
Expand Down

0 comments on commit 5561410

Please sign in to comment.