before_filter :authorize, :only => [:preferences, :api_details, :api_gpx_files]
before_filter :authorize_web, :only => [:edit, :account, :go_public, :view, :diary]
- before_filter :require_user, :only => [:edit, :account, :go_public]
-
+ before_filter :require_user, :only => [:edit, :set_home, :account, :go_public]
+
def save
@user = User.new(params[:user])
@user.set_defaults
def edit
if params[:user] and params[:user][:display_name] and params[:user][:description]
+ home_lat = params[:user][:home_lat]
+ home_lon = params[:user][:home_lon]
+
@user.display_name = params[:user][:display_name]
@user.description = params[:user][:description]
+ @user.home_lat = home_lat.to_f
+ @user.home_lon = home_lon.to_f
if @user.save
flash[:notice] = "User edited OK."
redirect_to :controller => 'user', :action => 'account'
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
+ @user.home_lat = params[:user][:home_lat].to_f
+ @user.home_lon = params[:user][:home_lon].to_f
+ if @user.save
+ flash[:notice] = "User home saved."
+ redirect_to :controller => 'user', :action => 'account'
+ end
end
+ end
def go_public
@user.data_public = true
has_many :traces
has_many :diary_entries
-
+
validates_confirmation_of :pass_crypt, :message => 'Password must match the confirmation password'
validates_uniqueness_of :display_name, :allow_nil => true
validates_uniqueness_of :email
el1['account_created'] = self.creation_time.xmlschema
return el1
end
+
+ def get_nearby_users
+ end
+
+
+
end
<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>user home</td><td>Latitude: <%=@user.home_lat%> Longitude <%=@user.home_lon%> (<%= 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>
+<h2>Users in your area</h2>
+
+These users are mapping in your area:
+
+
+
<h2>Privacy</h2>
<% if @user.data_public? %>
All your edits are public.
<table>
<tr><td>display name</td><td><%= text_field :user, :display_name, :value => @user.display_name %></td></tr>
<tr><td valign="top">description</td><td><%= text_area :user, :description, :value => @user.description %></td></tr>
+ <tr><td>home latitude</td><td><%= text_field :user, :home_lat, :value => @user.home_lat %></td>
+ <tr><td>home longitude</td><td><%= text_field :user, :home_lon, :value => @user.home_lon %></td>
+
</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 %>
map.connect '/user/:display_name/diary/newpost', :controller => 'diary_entry', :action => 'new'
map.connect '/user/:display_name/edit', :controller => 'user', :action => 'edit'
map.connect '/user/:display_name/account', :controller => 'user', :action => 'account'
+ map.connect '/user/:display_name/set_home', :controller => 'user', :action => 'set_home'
# test pages
map.connect '/test/populate/:table/:from/:count', :controller => 'test', :action => 'populate'
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);
+alter table users add column (home_lat double default NULL);
+alter table users add column (home_lon double default NULL);