Browse Source

Fix for registration confirmation

development
Godwin 9 years ago
parent
commit
450bb6a8f7
  1. 2
      app/controllers/conferences_controller.rb
  2. 6
      app/helpers/application_helper.rb

2
app/controllers/conferences_controller.rb

@ -558,7 +558,7 @@ class ConferencesController < ApplicationController
@errors[:name] = :empty @errors[:name] = :empty
end end
if params[:location].present? && params[:location].gsub(/[\s\W]/, '').present? && (l = Geocoder.search(params[:location], params: { language: 'en' })).present? if params[:location].present? && params[:location].gsub(/[\s\W]/, '').present? && (l = Geocoder.search(params[:location], language: 'en')).present?
corrected = view_context.location(l.first) corrected = view_context.location(l.first)
if corrected.present? if corrected.present?

6
app/helpers/application_helper.rb

@ -443,13 +443,13 @@ module ApplicationHelper
end end
def get_remote_location def get_remote_location
Geocoder.search(session['remote_ip'] || (session['remote_ip'] = open("http://checkip.dyndns.org").first.gsub(/^.*\s([\d\.]+).*$/s, '\1').gsub(/[^\.\d]/, '')), params: { language: 'en' }).first Geocoder.search(session['remote_ip'] || (session['remote_ip'] = open("http://checkip.dyndns.org").first.gsub(/^.*\s([\d\.]+).*$/s, '\1').gsub(/[^\.\d]/, '')), language: 'en').first
end end
def lookup_ip_location def lookup_ip_location
begin begin
if is_test? && ApplicationController::get_location.present? if is_test? && ApplicationController::get_location.present?
Geocoder.search(ApplicationController::get_location, params: { language: 'en' }).first Geocoder.search(ApplicationController::get_location, language: 'en').first
elsif request.remote_ip == '127.0.0.1' || request.remote_ip == '::1' elsif request.remote_ip == '127.0.0.1' || request.remote_ip == '::1'
get_remote_location get_remote_location
else else
@ -546,7 +546,7 @@ module ApplicationHelper
$panoramios ||= Hash.new $panoramios ||= Hash.new
$panoramios[location] ||= 0 $panoramios[location] ||= 0
$panoramios[location] += 1 $panoramios[location] += 1
result = Geocoder.search(location, params: { language: 'en' }).first result = Geocoder.search(location, language: 'en').first
if result if result
points = Geocoder::Calculations.bounding_box([result.latitude, result.longitude], 5, { :unit => :km }) points = Geocoder::Calculations.bounding_box([result.latitude, result.longitude], 5, { :unit => :km })
options = {:set => :public, :size => :original, :from => 0, :to => 20, :mapfilter => false, :miny => points[0], :minx => points[1], :maxy => points[2], :maxx => points[3]} options = {:set => :public, :size => :original, :from => 0, :to => 20, :mapfilter => false, :miny => points[0], :minx => points[1], :maxy => points[2], :maxx => points[3]}

Loading…
Cancel
Save