aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/application_controller.rb
diff options
context:
space:
mode:
authorHenare Degan <henare.degan@gmail.com>2013-03-14 14:33:17 +1100
committerHenare Degan <henare.degan@gmail.com>2013-03-14 14:33:17 +1100
commit48c6f8077429dd86da27a52be20c97cc583f31a9 (patch)
tree78d74660677a3a63659260c982dabfade692749d /app/controllers/application_controller.rb
parent2f6af09899e2822121d060db55fdd78b15f099db (diff)
parentd8a5de249bfeb41317d64e7efbaab71da1ede00d (diff)
Merge remote-tracking branch 'mysociety/develop' into rails-3-develop
Conflicts: Gemfile Gemfile.lock app/controllers/admin_request_controller.rb app/controllers/admin_track_controller.rb app/controllers/request_controller.rb app/controllers/services_controller.rb app/helpers/link_to_helper.rb app/mailers/request_mailer.rb app/models/application_mailer.rb app/models/info_request.rb app/views/admin_censor_rule/edit.html.erb app/views/admin_censor_rule/new.html.erb app/views/admin_public_body/_form.html.erb app/views/admin_public_body/_locale_selector.html.erb app/views/admin_public_body/_one_list.html.erb app/views/admin_public_body/edit.html.erb app/views/admin_public_body/list.html.erb app/views/admin_public_body/new.html.erb app/views/admin_request/_incoming_message_actions.html.erb app/views/admin_request/edit.html.erb app/views/admin_request/edit_comment.html.erb app/views/admin_request/edit_outgoing.html.erb app/views/admin_request/list.html.erb app/views/admin_request/list_old_unclassified.html.erb app/views/admin_request/show.html.erb app/views/admin_track/_some_tracks.html.erb app/views/admin_track/list.html.erb app/views/admin_user/edit.html.erb app/views/admin_user/list.html.erb app/views/admin_user/show.html.erb app/views/general/_footer.html.erb app/views/general/exception_caught.html.erb app/views/help/contact.html.erb app/views/layouts/default.html.erb app/views/public_body/_alphabet.html.erb app/views/request/_request_listing_single.html.erb app/views/request/_sidebar.html.erb app/views/request/new.html.erb app/views/request/show.html.erb app/views/request_mailer/external_response.rhtml app/views/request_mailer/fake_response.rhtml config/environment.rb config/environments/production.rb config/routes.rb spec/controllers/admin_censor_rule_controller_spec.rb spec/controllers/request_controller_spec.rb spec/controllers/track_controller_spec.rb spec/helpers/link_to_helper_spec.rb spec/mailers/request_mailer_spec.rb spec/models/info_request_spec.rb spec/spec_helper.rb spec/views/public_body/show.html.erb_spec.rb spec/views/request/show.html.erb_spec.rb vendor/plugins/rails_xss/lib/rails_xss/erubis.rb
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r--app/controllers/application_controller.rb30
1 files changed, 13 insertions, 17 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index a6df11ef7..df522519d 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -449,11 +449,7 @@ class ApplicationController < ActionController::Base
end
end
- def param_exists(item)
- return params[item] && !params[item].empty?
- end
-
- def get_request_variety_from_params
+ def get_request_variety_from_params(params)
query = ""
sortby = "newest"
varieties = []
@@ -475,7 +471,7 @@ class ApplicationController < ActionController::Base
return query
end
- def get_status_from_params
+ def get_status_from_params(params)
query = ""
if params[:latest_status]
statuses = []
@@ -510,24 +506,24 @@ class ApplicationController < ActionController::Base
return query
end
- def get_date_range_from_params
+ def get_date_range_from_params(params)
query = ""
- if param_exists(:request_date_after) && !param_exists(:request_date_before)
+ if params.has_key?(:request_date_after) && !params.has_key?(:request_date_before)
params[:request_date_before] = Time.now.strftime("%d/%m/%Y")
query += " #{params[:request_date_after]}..#{params[:request_date_before]}"
- elsif !param_exists(:request_date_after) && param_exists(:request_date_before)
+ elsif !params.has_key?(:request_date_after) && params.has_key?(:request_date_before)
params[:request_date_after] = "01/01/2001"
end
- if param_exists(:request_date_after)
+ if params.has_key?(:request_date_after)
query = " #{params[:request_date_after]}..#{params[:request_date_before]}"
end
return query
end
- def get_tags_from_params
+ def get_tags_from_params(params)
query = ""
tags = []
- if param_exists(:tags)
+ if params.has_key?(:tags)
params[:tags].split().each do |tag|
tags << "tag:#{tag}"
end
@@ -538,12 +534,12 @@ class ApplicationController < ActionController::Base
return query
end
- def make_query_from_params
+ def make_query_from_params(params)
query = params[:query] || "" if query.nil?
- query += get_date_range_from_params
- query += get_request_variety_from_params
- query += get_status_from_params
- query += get_tags_from_params
+ query += get_date_range_from_params(params)
+ query += get_request_variety_from_params(params)
+ query += get_status_from_params(params)
+ query += get_tags_from_params(params)
return query
end