Doing a resync from mainline 8633:10895. There was one simple to resolve conflict on app/models/node.rb. Also moving the migrations for API0.6 to new sequence numbers since there was some new migrations added to mainline, where the migration numbers would conflict if not moved.
This commit is contained in:
commit
d9e070e069
395 changed files with 2348 additions and 25020 deletions
File diff suppressed because it is too large
Load diff
|
@ -126,6 +126,14 @@ class ApiController < ApplicationController
|
|||
|
||||
doc = OSM::API.new.get_xml_doc
|
||||
|
||||
# add bounds
|
||||
bounds = XML::Node.new 'bounds'
|
||||
bounds['minlat'] = min_lat.to_s
|
||||
bounds['minlon'] = min_lon.to_s
|
||||
bounds['maxlat'] = max_lat.to_s
|
||||
bounds['maxlon'] = max_lon.to_s
|
||||
doc.root << bounds
|
||||
|
||||
# get ways
|
||||
# find which ways are needed
|
||||
ways = Array.new
|
||||
|
@ -168,15 +176,15 @@ class ApiController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
relations = visible_nodes.values.collect { |node| node.containing_relations.visible }.flatten +
|
||||
way_ids.collect { |id| Way.find(id).containing_relations.visible }.flatten
|
||||
relations = Relation.find_for_nodes(visible_nodes.keys, :conditions => "visible = 1") +
|
||||
Relation.find_for_ways(way_ids, :conditions => "visible = 1")
|
||||
|
||||
# we do not normally return the "other" partners referenced by an relation,
|
||||
# e.g. if we return a way A that is referenced by relation X, and there's
|
||||
# another way B also referenced, that is not returned. But we do make
|
||||
# an exception for cases where an relation references another *relation*;
|
||||
# in that case we return that as well (but we don't go recursive here)
|
||||
relations += relations.collect { |relation| relation.containing_relations.visible }.flatten
|
||||
relations += Relation.find_for_relations(relations.collect { |r| r.id }, :conditions => "visible = 1")
|
||||
|
||||
# this "uniq" may be slightly inefficient; it may be better to first collect and output
|
||||
# all node-related relations, then find the *not yet covered* way-related ones etc.
|
||||
|
|
|
@ -8,7 +8,7 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
def authorize_web
|
||||
if session[:user]
|
||||
@user = User.find(session[:user])
|
||||
@user = User.find(session[:user], :conditions => "visible = 1")
|
||||
elsif session[:token]
|
||||
@user = User.authenticate(:token => session[:token])
|
||||
session[:user] = @user.id
|
||||
|
|
|
@ -2,16 +2,40 @@ class DiaryEntryController < ApplicationController
|
|||
layout 'site', :except => :rss
|
||||
|
||||
before_filter :authorize_web
|
||||
before_filter :require_user, :only => [:new]
|
||||
before_filter :require_user, :only => [:new, :edit]
|
||||
before_filter :check_database_availability
|
||||
|
||||
def new
|
||||
@title = 'new diary entry'
|
||||
@title = 'New diary entry'
|
||||
|
||||
if params[:diary_entry]
|
||||
@diary_entry = DiaryEntry.new(params[:diary_entry])
|
||||
@diary_entry.user = @user
|
||||
|
||||
if @diary_entry.save
|
||||
redirect_to :controller => 'diary_entry', :action => 'list', :display_name => @user.display_name
|
||||
else
|
||||
render :action => 'edit'
|
||||
end
|
||||
else
|
||||
render :action => 'edit'
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@title= 'Edit diary entry'
|
||||
@diary_entry = DiaryEntry.find(params[:id])
|
||||
|
||||
if @user != @diary_entry.user
|
||||
redirect_to :controller => 'diary_entry', :action => 'view', :id => params[:id]
|
||||
elsif params[:diary_entry]
|
||||
@diary_entry.title = params[:diary_entry][:title]
|
||||
@diary_entry.body = params[:diary_entry][:body]
|
||||
@diary_entry.latitude = params[:diary_entry][:latitude]
|
||||
@diary_entry.longitude = params[:diary_entry][:longitude]
|
||||
|
||||
if @diary_entry.save
|
||||
redirect_to :controller => 'diary_entry', :action => 'view', :id => params[:id]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -27,10 +51,11 @@ class DiaryEntryController < ApplicationController
|
|||
render :action => 'view'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def list
|
||||
if params[:display_name]
|
||||
@this_user = User.find_by_display_name(params[:display_name])
|
||||
@this_user = User.find_by_display_name(params[:display_name], :conditions => "visible = 1")
|
||||
|
||||
if @this_user
|
||||
@title = @this_user.display_name + "'s diary"
|
||||
@entry_pages, @entries = paginate(:diary_entries,
|
||||
|
@ -39,6 +64,7 @@ class DiaryEntryController < ApplicationController
|
|||
:per_page => 20)
|
||||
else
|
||||
@not_found_user = params[:display_name]
|
||||
|
||||
render :action => 'no_such_user', :status => :not_found
|
||||
end
|
||||
else
|
||||
|
@ -51,23 +77,37 @@ class DiaryEntryController < ApplicationController
|
|||
|
||||
def rss
|
||||
if params[:display_name]
|
||||
user = User.find_by_display_name(params[:display_name])
|
||||
@entries = DiaryEntry.find(:all, :conditions => ['user_id = ?', user.id], :order => 'created_at DESC', :limit => 20)
|
||||
@title = "OpenStreetMap diary entries for #{user.display_name}"
|
||||
@description = "Recent OpenStreetmap diary entries from #{user.display_name}"
|
||||
@link = "http://www.openstreetmap.org/user/#{user.display_name}/diary"
|
||||
user = User.find_by_display_name(params[:display_name], :conditions => "visible = 1")
|
||||
|
||||
if user
|
||||
@entries = DiaryEntry.find(:all, :conditions => ['user_id = ?', user.id], :order => 'created_at DESC', :limit => 20)
|
||||
@title = "OpenStreetMap diary entries for #{user.display_name}"
|
||||
@description = "Recent OpenStreetmap diary entries from #{user.display_name}"
|
||||
@link = "http://www.openstreetmap.org/user/#{user.display_name}/diary"
|
||||
|
||||
render :content_type => Mime::RSS
|
||||
else
|
||||
render :nothing => true, :status => :not_found
|
||||
end
|
||||
else
|
||||
@entries = DiaryEntry.find(:all, :order => 'created_at DESC', :limit => 20)
|
||||
@title = "OpenStreetMap diary entries"
|
||||
@description = "Recent diary entries from users of OpenStreetMap"
|
||||
@link = "http://www.openstreetmap.org/diary"
|
||||
end
|
||||
|
||||
render :content_type => Mime::RSS
|
||||
render :content_type => Mime::RSS
|
||||
end
|
||||
end
|
||||
|
||||
def view
|
||||
user = User.find_by_display_name(params[:display_name])
|
||||
@entry = DiaryEntry.find(:first, :conditions => ['user_id = ? AND id = ?', user.id, params[:id]])
|
||||
user = User.find_by_display_name(params[:display_name], :conditions => "visible = 1")
|
||||
|
||||
if user
|
||||
@entry = DiaryEntry.find(:first, :conditions => ['user_id = ? AND id = ?', user.id, params[:id]])
|
||||
else
|
||||
@not_found_user = params[:display_name]
|
||||
|
||||
render :action => 'no_such_user', :status => :not_found
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -117,8 +117,8 @@ class SwfController < ApplicationController
|
|||
def startShape
|
||||
s =0.chr # No fill styles
|
||||
s+=2.chr # Two line styles
|
||||
s+=packUI16(5) + 0.chr + 255.chr + 255.chr # Width 5, RGB #00FFFF
|
||||
s+=packUI16(5) + 255.chr + 0.chr + 255.chr # Width 5, RGB #FF00FF
|
||||
s+=packUI16(0) + 0.chr + 255.chr + 255.chr # Width 5, RGB #00FFFF
|
||||
s+=packUI16(0) + 255.chr + 0.chr + 255.chr # Width 5, RGB #FF00FF
|
||||
s+=34.chr # 2 fill, 2 line index bits
|
||||
s
|
||||
end
|
||||
|
|
|
@ -12,13 +12,13 @@ class TraceController < ApplicationController
|
|||
# from display name, pick up user id if one user's traces only
|
||||
display_name = params[:display_name]
|
||||
if target_user.nil? and !display_name.blank?
|
||||
target_user = User.find(:first, :conditions => [ "display_name = ?", display_name])
|
||||
target_user = User.find(:first, :conditions => [ "visible = 1 and display_name = ?", display_name])
|
||||
end
|
||||
|
||||
# set title
|
||||
if target_user.nil?
|
||||
@title = "Public GPS traces"
|
||||
elsif @user and @user.id == target_user.id
|
||||
elsif @user and @user == target_user
|
||||
@title = "Your GPS traces"
|
||||
else
|
||||
@title = "Public GPS traces from #{target_user.display_name}"
|
||||
|
@ -38,7 +38,7 @@ class TraceController < ApplicationController
|
|||
conditions = ["gpx_files.public = 1"] #2
|
||||
end
|
||||
else
|
||||
if @user and @user.id == target_user.id
|
||||
if @user and @user == target_user
|
||||
conditions = ["gpx_files.user_id = ?", @user.id] #3 (check vs user id, so no join + can't pick up non-public traces by changing name)
|
||||
else
|
||||
conditions = ["gpx_files.public = 1 AND gpx_files.user_id = ?", target_user.id] #4
|
||||
|
@ -88,7 +88,7 @@ class TraceController < ApplicationController
|
|||
@trace = Trace.find(params[:id])
|
||||
|
||||
if @trace and @trace.visible? and
|
||||
(@trace.public? or @trace.user.id == @user.id)
|
||||
(@trace.public? or @trace.user == @user)
|
||||
@title = "Viewing trace #{@trace.name}"
|
||||
else
|
||||
flash[:notice] = "Trace not found!"
|
||||
|
|
|
@ -2,8 +2,8 @@ class UserController < ApplicationController
|
|||
layout 'site'
|
||||
|
||||
before_filter :authorize, :only => [:api_details, :api_gpx_files]
|
||||
before_filter :authorize_web, :only => [:account, :go_public, :view, :diary, :make_friend, :remove_friend, :upload_image]
|
||||
before_filter :require_user, :only => [:set_home, :account, :go_public, :make_friend, :remove_friend, :upload_image]
|
||||
before_filter :authorize_web, :except => [:api_details, :api_gpx_files]
|
||||
before_filter :require_user, :only => [:set_home, :account, :go_public, :make_friend, :remove_friend, :upload_image, :delete_image]
|
||||
before_filter :check_database_availability, :except => [:api_details, :api_gpx_files]
|
||||
before_filter :check_read_availability, :only => [:api_details, :api_gpx_files]
|
||||
|
||||
|
@ -13,12 +13,13 @@ class UserController < ApplicationController
|
|||
@title = 'create account'
|
||||
@user = User.new(params[:user])
|
||||
|
||||
@user.visible = true
|
||||
@user.data_public = true
|
||||
|
||||
@user.description = "" if @user.description.nil?
|
||||
|
||||
if @user.save
|
||||
token = @user.tokens.create
|
||||
flash[:notice] = "User was successfully created. Check your email for a confirmation note, and you\'ll be mapping in no time :-)<br>Please note that you won't be able to login until you've received and confirmed your email address."
|
||||
Notifier::deliver_signup_confirm(@user, token)
|
||||
Notifier.deliver_signup_confirm(@user, @user.tokens.create)
|
||||
redirect_to :action => 'login'
|
||||
else
|
||||
render :action => 'new'
|
||||
|
@ -28,21 +29,28 @@ class UserController < ApplicationController
|
|||
def account
|
||||
@title = 'edit account'
|
||||
if params[:user] and params[:user][:display_name] and params[:user][:description]
|
||||
home_lat = params[:user][:home_lat]
|
||||
home_lon = params[:user][:home_lon]
|
||||
if params[:user][:email] != @user.email
|
||||
@user.new_email = params[:user][:email]
|
||||
end
|
||||
|
||||
@user.display_name = params[:user][:display_name]
|
||||
|
||||
if params[:user][:pass_crypt].length > 0 or params[:user][:pass_crypt_confirmation].length > 0
|
||||
@user.pass_crypt = params[:user][:pass_crypt]
|
||||
@user.pass_crypt_confirmation = params[:user][:pass_crypt_confirmation]
|
||||
end
|
||||
|
||||
@user.description = params[:user][:description]
|
||||
@user.home_lat = home_lat
|
||||
@user.home_lon = home_lon
|
||||
@user.home_lat = params[:user][:home_lat]
|
||||
@user.home_lon = params[:user][:home_lon]
|
||||
|
||||
if @user.save
|
||||
flash[:notice] = "User information updated successfully."
|
||||
else
|
||||
flash.delete(:notice)
|
||||
if params[:user][:email] == @user.new_email
|
||||
@notice = "User information updated successfully. Check your email for a note to confirm your new email address."
|
||||
Notifier.deliver_email_confirm(@user, @user.tokens.create)
|
||||
else
|
||||
@notice = "User information updated successfully."
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -68,16 +76,15 @@ class UserController < ApplicationController
|
|||
def lost_password
|
||||
@title = 'lost password'
|
||||
if params[:user] and params[:user][:email]
|
||||
user = User.find_by_email(params[:user][:email])
|
||||
user = User.find_by_email(params[:user][:email], :conditions => "visible = 1")
|
||||
|
||||
if user
|
||||
token = user.tokens.create
|
||||
Notifier::deliver_lost_password(user, token)
|
||||
flash[:notice] = "Sorry you lost it :-( but an email is on its way so you can reset it soon."
|
||||
Notifier.deliver_lost_password(user, token)
|
||||
@notice = "Sorry you lost it :-( but an email is on its way so you can reset it soon."
|
||||
else
|
||||
flash[:notice] = "Couldn't find that email address, sorry."
|
||||
@notice = "Couldn't find that email address, sorry."
|
||||
end
|
||||
else
|
||||
render :action => 'lost_password'
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -91,14 +98,16 @@ class UserController < ApplicationController
|
|||
user.pass_crypt = pass
|
||||
user.pass_crypt_confirmation = pass
|
||||
user.active = true
|
||||
user.email_valid = true
|
||||
user.save!
|
||||
token.destroy
|
||||
Notifier::deliver_reset_password(user, pass)
|
||||
Notifier.deliver_reset_password(user, pass)
|
||||
flash[:notice] = "Your password has been changed and is on its way to your mailbox :-)"
|
||||
else
|
||||
flash[:notice] = "Didn't find that token, check the URL maybe?"
|
||||
end
|
||||
end
|
||||
|
||||
redirect_to :action => 'login'
|
||||
end
|
||||
|
||||
|
@ -121,9 +130,9 @@ class UserController < ApplicationController
|
|||
end
|
||||
return
|
||||
elsif User.authenticate(:username => email_or_display_name, :password => pass, :inactive => true)
|
||||
flash[:notice] = "Sorry, your account is not active yet.<br>Please click on the link in the account confirmation email to activate your account."
|
||||
@notice = "Sorry, your account is not active yet.<br>Please click on the link in the account confirmation email to activate your account."
|
||||
else
|
||||
flash[:notice] = "Sorry, couldn't log in with those details."
|
||||
@notice = "Sorry, couldn't log in with those details."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -150,13 +159,34 @@ class UserController < ApplicationController
|
|||
if token and !token.user.active?
|
||||
@user = token.user
|
||||
@user.active = true
|
||||
@user.email_valid = true
|
||||
@user.save!
|
||||
token.destroy
|
||||
flash[:notice] = 'Confirmed your account, thanks for signing up!'
|
||||
session[:user] = @user.id
|
||||
redirect_to :action => 'account', :display_name => @user.display_name
|
||||
else
|
||||
flash[:notice] = 'Something went wrong confirming that user.'
|
||||
@notice = 'Something went wrong confirming that user.'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def confirm_email
|
||||
if params[:confirm_action]
|
||||
token = UserToken.find_by_token(params[:confirm_string])
|
||||
if token and token.user.new_email?
|
||||
@user = token.user
|
||||
@user.email = @user.new_email
|
||||
@user.new_email = nil
|
||||
@user.active = true
|
||||
@user.email_valid = true
|
||||
@user.save!
|
||||
token.destroy
|
||||
flash[:notice] = 'Confirmed your email address, thanks for signing up!'
|
||||
session[:user] = @user.id
|
||||
redirect_to :action => 'account', :display_name => @user.display_name
|
||||
else
|
||||
@notice = 'Something went wrong confirming that email address.'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -167,6 +197,12 @@ class UserController < ApplicationController
|
|||
redirect_to :controller => 'user', :action => 'view', :display_name => @user.display_name
|
||||
end
|
||||
|
||||
def delete_image
|
||||
@user.image = nil
|
||||
@user.save!
|
||||
redirect_to :controller => 'user', :action => 'view', :display_name => @user.display_name
|
||||
end
|
||||
|
||||
def api_details
|
||||
render :text => @user.to_xml.to_s, :content_type => "text/xml"
|
||||
end
|
||||
|
@ -180,7 +216,7 @@ class UserController < ApplicationController
|
|||
end
|
||||
|
||||
def view
|
||||
@this_user = User.find_by_display_name(params[:display_name])
|
||||
@this_user = User.find_by_display_name(params[:display_name], :conditions => "visible = 1")
|
||||
|
||||
if @this_user
|
||||
@title = @this_user.display_name
|
||||
|
@ -193,20 +229,21 @@ class UserController < ApplicationController
|
|||
def make_friend
|
||||
if params[:display_name]
|
||||
name = params[:display_name]
|
||||
new_friend = User.find_by_display_name(name)
|
||||
new_friend = User.find_by_display_name(name, :conditions => "visible = 1")
|
||||
friend = Friend.new
|
||||
friend.user_id = @user.id
|
||||
friend.friend_user_id = new_friend.id
|
||||
unless @user.is_friends_with?(new_friend)
|
||||
if friend.save
|
||||
flash[:notice] = "#{name} is now your friend."
|
||||
Notifier::deliver_friend_notification(friend)
|
||||
Notifier.deliver_friend_notification(friend)
|
||||
else
|
||||
friend.add_error("Sorry, failed to add #{name} as a friend.")
|
||||
end
|
||||
else
|
||||
flash[:notice] = "You are already friends with #{name}."
|
||||
end
|
||||
|
||||
redirect_to :controller => 'user', :action => 'view'
|
||||
end
|
||||
end
|
||||
|
@ -214,16 +251,15 @@ class UserController < ApplicationController
|
|||
def remove_friend
|
||||
if params[:display_name]
|
||||
name = params[:display_name]
|
||||
friend = User.find_by_display_name(name)
|
||||
friend = User.find_by_display_name(name, :conditions => "visible = 1")
|
||||
if @user.is_friends_with?(friend)
|
||||
Friend.delete_all "user_id = #{@user.id} AND friend_user_id = #{friend.id}"
|
||||
flash[:notice] = "#{friend.display_name} was removed from your friends."
|
||||
else
|
||||
flash[:notice] = "#{friend.display_name} was not already one of your friends."
|
||||
flash[:notice] = "#{friend.display_name} is not one of your friends."
|
||||
end
|
||||
|
||||
redirect_to :controller => 'user', :action => 'view'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue