diff options
-rw-r--r-- | app/controllers/application_controller.rb | 11 | ||||
-rw-r--r-- | app/controllers/general_controller.rb | 4 | ||||
-rw-r--r-- | app/controllers/user_controller.rb | 11 | ||||
-rw-r--r-- | app/views/user/_signup.rhtml | 8 | ||||
-rw-r--r-- | config/crontab.ugly | 2 | ||||
-rw-r--r-- | config/general.yml-example | 9 |
6 files changed, 32 insertions, 13 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. diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb index 2d0527d3a..1ddf3acff 100644 --- a/app/controllers/general_controller.rb +++ b/app/controllers/general_controller.rb @@ -45,10 +45,6 @@ class GeneralController < ApplicationController :joins => :translations) end end - @search_examples = MySociety::Config.get('FRONTPAGE_SEARCH_EXAMPLES', '').split(/\s*;\s*/) - if @search_examples.empty? - @search_examples = @popular_bodies.map { |body| body.name } - end # Get some successful requests # begin query = 'variety:response (status:successful OR status:partially_successful)' diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 8e4fb29ef..6916b4456 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -71,7 +71,7 @@ class UserController < ApplicationController # Login form def signin work_out_post_redirect - + @request_from_foreign_country = country_from_ip != MySociety::Config.get('ISO_COUNTRY_CODE', 'GB') # make sure we have cookies if session.instance_variable_get(:@dbman) if not session.instance_variable_get(:@dbman).instance_variable_get(:@original) @@ -118,10 +118,15 @@ class UserController < ApplicationController # Create new account form def signup work_out_post_redirect - + @request_from_foreign_country = country_from_ip != MySociety::Config.get('ISO_COUNTRY_CODE', 'GB') # Make the user and try to save it @user_signup = User.new(params[:user_signup]) - if !@user_signup.valid? + error = false + if @request_from_foreign_country && !verify_recaptcha + flash.now[:error] = _("There was an error with the words you entered, please try again.") + error = true + end + if error || !@user_signup.valid? # Show the form render :action => 'sign' else diff --git a/app/views/user/_signup.rhtml b/app/views/user/_signup.rhtml index 9c228d684..f183ac1f1 100644 --- a/app/views/user/_signup.rhtml +++ b/app/views/user/_signup.rhtml @@ -10,8 +10,8 @@ <%= text_field 'user_signup', 'email', { :size => 20 } %> </p> <div class="form_item_note"> - <%= ('We will not reveal your email address to anybody unless you or - the law tell us to (<a href="%s">_details</a>). ') %[help_privacy_path] %> + <%= _('We will not reveal your email address to anybody unless you or + the law tell us to (<a href="%s">details</a>). ') %[help_privacy_path] %> </div> <p> @@ -36,6 +36,10 @@ <%= password_field 'user_signup', 'password_confirmation', { :size => 15 } %> </p> + <% if @request_from_foreign_country %> + <%= recaptcha_tags %> + <% end %> + <div class="form_button"> <%= hidden_field_tag 'token', params[:token], { :id => 'signup_token' } %> <%= submit_tag _('Sign up') %> diff --git a/config/crontab.ugly b/config/crontab.ugly index ecd3151ff..5f2fbdb3b 100644 --- a/config/crontab.ugly +++ b/config/crontab.ugly @@ -28,7 +28,7 @@ MAILTO=cron-!!(*= $site *)!!@mysociety.org 2 4 * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/check-recent-requests-sent.lock /data/vhost/!!(*= $vhost *)!!/!!(*= $vcspath *)!!/script/check-recent-requests-sent || echo "stalled?" 45 3 * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/stop-new-responses-on-old-requests.lock /data/vhost/!!(*= $vhost *)!!/!!(*= $vcspath *)!!/script/stop-new-responses-on-old-requests || echo "stalled?" # Only root can restart apache -31 1 * * * root run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/compact-xapian-database.lock /data/vhost/!!(*= $vhost *)!!/!!(*= $vcspath *)!!/script/compact-xapian-database production || echo "stalled?" +31 1 * * * root run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/compact-xapian-database.lock "/data/vhost/!!(*= $vhost *)!!/!!(*= $vcspath *)!!/script/compact-xapian-database production" || echo "stalled?" # Once a day on all servers diff --git a/config/general.yml-example b/config/general.yml-example index 5eee675ff..48e8523ef 100644 --- a/config/general.yml-example +++ b/config/general.yml-example @@ -12,6 +12,10 @@ SITE_NAME: 'Alaveteli' # Domain used in URLs generated by scripts (e.g. for going in some emails) DOMAIN: '127.0.0.1:3000' +# ISO country code of country currrently deployed in +# (http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) +ISO_COUNTRY_CODE: GB + # These feeds are displayed accordingly on the Alaveteli "blog" page: BLOG_FEED: 'http://www.mysociety.org/category/projects/whatdotheyknow/feed/' TWITTER_USERNAME: 'whatdotheyknow' @@ -27,9 +31,6 @@ REPLY_VERY_LATE_AFTER_DAYS: 40 # We give some types of authority like schools a bit longer than everyone else SPECIAL_REPLY_VERY_LATE_AFTER_DAYS: 60 -# example searches for the home page, semicolon delimited. -FRONTPAGE_SEARCH_EXAMPLES: 'Geraldine Quango; Department for Humpadinking' - # example public bodies for the home page, semicolon delimited - short_names FRONTPAGE_PUBLICBODY_EXAMPLES: 'tgq' @@ -109,3 +110,5 @@ DEBUG_RECORD_MEMORY: false # be another reason to try this setting. USE_GHOSTSCRIPT_COMPRESSION: true +# mySociety's gazeteer service. Shouldn't change. +GAZE_URL: http://gaze.mysociety.org |