]> git.openstreetmap.org Git - rails.git/commitdiff
Fixed up name search and postcode search
authorNick Black <nickb@svn.openstreetmap.org>
Wed, 25 Apr 2007 08:12:20 +0000 (08:12 +0000)
committerNick Black <nickb@svn.openstreetmap.org>
Wed, 25 Apr 2007 08:12:20 +0000 (08:12 +0000)
app/controllers/geocoder_controller.rb
app/controllers/user_controller.rb
app/views/user/account.rhtml
app/views/user/edit.rhtml
db/migrate.sql

index c12c0525bea7258981ffbcac7e6847669ea029be..6955579ed952e9953db7eb0366d649eaf6d31836 100644 (file)
@@ -7,7 +7,7 @@ class GeocoderController < ApplicationController
   def search
     @postcode_arr = []
 
-    if params[:query][:postcode] 
+    unless params[:query][:postcode].empty? 
       postcode = params[:query][:postcode].upcase
       escaped_postcode = postcode.sub(/\s/,'%20')
 
@@ -68,7 +68,7 @@ class GeocoderController < ApplicationController
         end
         redirect_to "/index.html?lat=#{lat}&lon=#{lon}&zoom=14"
         #redirect_to "/index.html?error=unknown_postcode_or_zip"
-      else
+      elsif
         # Some other postcode / zip code
         # Throw it at geonames, and see if they have any luck with it
         Net::HTTP.start('ws.geonames.org') do |http|
@@ -85,11 +85,11 @@ class GeocoderController < ApplicationController
           lon = data_lon.split(/[<>]/)[1]
           redirect_to "/index.html?lat=#{lat}&lon=#{lon}&zoom=14"
         end
+      else
+        # Some other postcode / zip file
+        redirect_to "/index.html?error=unknown_postcode_or_zip"
+        return
       end
-    else
-      # Some other postcode / zip file
-      redirect_to "/index.html?error=unknown_postcode_or_zip"
-      return
     end
 
     if params[:query][:place_name]  
index 3837d097609512816176798d7d7339d72d011c8a..b2ac3072cae18d3e30c52978576b24aba2bf685d 100644 (file)
@@ -29,6 +29,18 @@ class UserController < ApplicationController
     end
   end
 
+  def set_home
+    if params[:user][:home_lat] and params[:user][:home_lon]
+    lat = params[:user][:home_lat]
+    lon = params[:user][:home_lon]
+    unless 
+      #check the lat and lon
+    end
+    #make an api request to insert a new node
+    #get the onde id
+    end
+    end
+
   def go_public
     @user.data_public = true
     @user.save
index f8047d3d880413206494f1b1c96f53e756719614..257e8c47abb53a1904c5583cf3a82d2e1fdf2020 100644 (file)
@@ -4,6 +4,7 @@
   <tr><td>email</td><td><%= @user.email %></td></tr>
   <tr><td>display name</td><td><%= @user.display_name %> (<%= link_to 'change...', :controller => 'user', :action => 'edit' %>)</td></tr>
   <tr><td>account created</td><td><%= @user.creation_time %> (<%= time_ago_in_words(@user.creation_time) %> ago)</td></tr>
+  <tr><td>user home</td><td><%= @user.home_node_id %>  (<%= link_to 'change...', :controller => 'user', :action => 'edit' %>) </td></tr>
   <tr><td valign="top">description</td><td><%= simple_format(@user.description) %>  (<%= link_to 'change...', :controller => 'user', :action => 'edit' %>)</td></tr>
 </table>
 
index 6c30ef0b33a00a7f00941a8fef8cbfd6f65f4272..a78b9e17325743a3c3b35261965da89d43d0a5f6 100644 (file)
@@ -7,3 +7,8 @@
 </table>
 <%= submit_tag 'Change' %>
 <%= end_form_tag %>
+
+<%= start_form_tag :controller => 'user', :action => 'set_home' %>
+  <tr><td>home location</td><td><%= text_field :user, :home  %></td></tr>
+<%= submit_tag 'Change Home' %>
+<%= end_form_tag %>
index dc81e5d0c315d357243161ddfad7ed56ac5ecfe1..0f78b9dd35874c07ad803a57bb188bb2e3317b14 100644 (file)
@@ -39,5 +39,5 @@ create table diary_entries(id bigint not null auto_increment, user_id bigint not
 alter table diary_entries add created_at datetime;
 alter table diary_entries add updated_at datetime;
 
-
+alter table users add column (home_node_id bigint(64) default NULL);