diff options
author | Seb Bacon <seb.bacon@gmail.com> | 2011-08-30 15:35:25 +0100 |
---|---|---|
committer | Seb Bacon <seb.bacon@gmail.com> | 2011-08-30 15:35:25 +0100 |
commit | 9c7799903ccf5551df496b7a57e564808089ed30 (patch) | |
tree | 2d71f55483cd66b926397f89efcef4dbcb3adaf4 /app/controllers/application_controller.rb | |
parent | 0420098e50996a033552335e94e35ade781357af (diff) | |
parent | a2817f8877a5e37962f81dd96f5ef79ad4a6b0c4 (diff) |
Merge branch 'feature/add-recaptcha' into develop
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r-- | app/controllers/application_controller.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 49b7fd7f1..6d14d0d7a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -454,6 +454,17 @@ class ApplicationController < ActionController::Base return query end + def country_from_ip + gaze = MySociety::Config.get('GAZE_URL', '') + default = MySociety::Config.get('ISO_COUNTRY_CODE', '') + country = "" + if !gaze.empty? + country = open("#{gaze}/gaze-rest?f=get_country_from_ip;ip=#{request.remote_ip}").read.strip + end + country = default if country.empty? + return country + end + # URL generating functions are needed by all controllers (for redirects), # views (for links) and mailers (for use in emails), so include them into # all of all. |