remove duplication in mobile cookie handling

This commit is contained in:
Matt Rogers 2012-08-15 22:14:00 -05:00
parent 580cad7ad8
commit 306d501e20

View file

@ -510,13 +510,7 @@ class TodosController < ApplicationController
format.xml { render :xml => @todo.to_xml( *to_xml_params ) }
format.m do
if @saved
if cookies[:mobile_url]
old_path = cookies[:mobile_url]
cookies[:mobile_url] = {:value => nil, :secure => SITE_CONFIG['secure_cookies']}
redirect_to old_path
else
redirect_to todos_path(:format => 'm')
end
do_mobile_todo_redirection
else
render :action => "edit", :format => :m
end
@ -798,14 +792,8 @@ class TodosController < ApplicationController
format.html { redirect_to :back }
format.js {render :action => 'update'}
format.m {
notify(:notice, t("todos.action_deferred", :description => @todo.description))
if cookies[:mobile_url]
old_path = cookies[:mobile_url]
cookies[:mobile_url] = {:value => nil, :secure => SITE_CONFIG['secure_cookies']}
redirect_to old_path
else
redirect_to todos_path(:format => 'm')
end
notify(:notice, t("todos.action_deferred", :description => @todo.description))
do_mobile_todo_redirection
}
end
end
@ -926,6 +914,16 @@ class TodosController < ApplicationController
private
def do_mobile_todo_redirection
if cookies[:mobile_url]
old_path = cookies[:mobile_url]
cookies[:mobile_url] = {:value => nil, :secure => SITE_CONFIG['secure_cookies']}
redirect_to old_path
else
redirect_to todos_path(:format => 'm')
end
end
def to_xml_params
if params[:limit_fields] == 'index'
return [:only => [:id, :created_at, :updated_at, :completed_at] ]