]> git.openstreetmap.org Git - rails.git/commitdiff
map view defaults to a home lat and lon
authorNick Black <nickb@svn.openstreetmap.org>
Mon, 30 Apr 2007 09:57:54 +0000 (09:57 +0000)
committerNick Black <nickb@svn.openstreetmap.org>
Mon, 30 Apr 2007 09:57:54 +0000 (09:57 +0000)
app/controllers/api_controller.rb
app/controllers/user_controller.rb
app/models/user.rb
app/views/site/index.rhtml
app/views/user/account.rhtml
db/migrate.sql

index 8091aa67af06e67489a1c55f9394faaf168769ea..7451a91b9b347bc113731f553eb437fcac380196 100644 (file)
@@ -3,6 +3,13 @@ class ApiController < ApplicationController
   before_filter :authorize
   after_filter :compress_output
 
   before_filter :authorize
   after_filter :compress_output
 
+  helper :user
+  model :user
+
+  def authorize_web
+    @current_user = User.find_by_token(session[:token])
+  end
+  
   # The maximum area you're allowed to request, in square degrees
   MAX_REQUEST_AREA = 0.25
 
   # The maximum area you're allowed to request, in square degrees
   MAX_REQUEST_AREA = 0.25
 
index 5b370334cc0c145f90f3d5c0e57d61c7c2ff963f..354e8c66f2ea6b252b53cbd7899589253f98f8c8 100644 (file)
@@ -162,7 +162,16 @@ class UserController < ApplicationController
   def diary
     @this_user = User.find_by_display_name(params[:display_name])
   end
   def diary
     @this_user = User.find_by_display_name(params[:display_name])
   end
-
+  
+  def contact_others(user_id, message_body)
+    @to = User.find_by_id(user_id)
+    @to.messages.new = body
+    if @to.save
+      flash[:notice] = Message sent
+    end
+    
+    #Send a message to other users - maybe there's a rails messaging plugin
+  end
 
 end
 
 
 end
 
index cd0623bc1a628591f8fe0865b964fabe44272f9f..1ecc3f7102a616dbe39010b5b6b7bd646b8f9994 100644 (file)
@@ -58,7 +58,10 @@ class User < ActiveRecord::Base
     return el1
   end
   
     return el1
   end
   
-  def get_nearby_users
+  def nearby(lat_range=1, lon_range=1)
+     
+      nearby = User.find(:all,  :conditions => "#{self.home_lon} > home_lon - #{lon_range} and #{self.home_lon} < home_lon + #{lon_range} and  #{self.home_lon} > home_lon - #{lon_range} and #{self.home_lon} < home_lon + #{lon_range} and data_public = 1") 
+      return nearby
   end
 
 
   end
 
 
index 31b0a480e07d96015d1603511adf3ab24d49456b..7c1c083b708737fdff70351103e8f55bb5d9a6c8 100644 (file)
@@ -20,9 +20,15 @@ eg:Essen
 </div>
 </div>
 
 </div>
 </div>
 
+<% if @user and params['lon'].nil? and params['lat'].nil? %> 
+<% lon =  @user.home_lon %>
+<% lat =  @user.home_lat %>
+<% zoom = '10' %>
+<%else%>
 <% lon =  params['lon'] || '-0.1' %>
 <% lat =  params['lat'] || '51.5' %>
 <% zoom =  params['zoom'] || '4' %>
 <% lon =  params['lon'] || '-0.1' %>
 <% lat =  params['lat'] || '51.5' %>
 <% zoom =  params['zoom'] || '4' %>
+<% end %>
 
 <script type="text/javascript">
   var lon = <%= lon %>;
 
 <script type="text/javascript">
   var lon = <%= lon %>;
index 90433f825450e29ab44c7c9c59560daacdd32c1e..77930d0b0ec02670dceb7cad06c566092dc1d162 100644 (file)
 
 <h2>Users in your area</h2>
 
 
 <h2>Users in your area</h2>
 
-These users are mapping in your area:
+<% if @user.nearby.empty? %>
+There are no users mapping in your area.  Better go out and spread the word about OSM!
+<% else %>
+
+<p>These users are mapping in your area:</p>
+<table>
+<tr>
+<th>Email</th>
+<th>Name</th>
+<th>Contact</th>
+</tr>
+<% @user.nearby(1,1).each do |nearby| %>
 
 
+<tr>
+<td><%= nearby.email %></td>
+<td><%= nearby.display_name %></td>
+<td>FIXME: send user an email</td>
+</tr>
+<%end%>
+</table>
 
 
+<%end%>
+<br />
+FIXME: OL Map showing the users on
 
 <h2>Privacy</h2>
 <% if @user.data_public? %>
 
 <h2>Privacy</h2>
 <% if @user.data_public? %>
index f953eec25998169200680864d616dce99b657a0a..abd9ec580865838b245deea4e08483e0fd1822c4 100644 (file)
@@ -41,4 +41,7 @@ alter table diary_entries add updated_at datetime;
 
 alter table users add column (home_lat double default NULL);
 alter table users add column (home_lon double default NULL);
 
 alter table users add column (home_lat double default NULL);
 alter table users add column (home_lon double default NULL);
+alter table users add column within_lon double default null;
+alter table users add column within_lat double default null;
 
 
+create table messages (id bigint not null auto_increment, user_id bigint(20) not null, title varchar(255), body text, sent_on datetime, message_read boolean default 0, primary key(id));