Merge 16355:16480 from trunk.

This commit is contained in:
Tom Hughes 2009-07-13 23:28:02 +00:00
commit 942ca1ff23
36 changed files with 2460 additions and 210 deletions

View file

@ -302,7 +302,7 @@ class AmfController < ApplicationController
end
# Get a way including nodes and tags.
# Returns the way id, a Potlatch-style array of points, a hash of tags, and the version number.
# Returns the way id, a Potlatch-style array of points, a hash of tags, the version number, and the user ID.
def getway(wayid) #:doc:
amf_handle_error_with_timeout("'getway' #{wayid}") do
@ -310,6 +310,7 @@ class AmfController < ApplicationController
points = sql_get_nodes_in_way(wayid)
tags = sql_get_tags_in_way(wayid)
version = sql_get_way_version(wayid)
uid = sql_get_way_user(wayid)
else
# Ideally we would do ":include => :nodes" here but if we do that
# then rails only seems to return the first copy of a node when a
@ -326,9 +327,10 @@ class AmfController < ApplicationController
end
tags = way.tags
version = way.version
uid = way.changeset.user.id
end
[0, '', wayid, points, tags, version]
[0, '', wayid, points, tags, version, uid]
end
end
@ -415,7 +417,8 @@ class AmfController < ApplicationController
# Remove any elements where 2 seconds doesn't elapse before next one
revdates.delete_if { |d| revdates.include?(d+1) or revdates.include?(d+2) }
# Collect all in one nested array
revdates.collect! {|d| [d.strftime("%d %b %Y, %H:%M:%S")] + revusers[d.to_i] }
revdates.collect! {|d| [d.succ.strftime("%d %b %Y, %H:%M:%S")] + revusers[d.to_i] }
revdates.uniq!
return ['way', wayid, revdates]
rescue ActiveRecord::RecordNotFound
@ -428,7 +431,7 @@ class AmfController < ApplicationController
def getnode_history(nodeid) #:doc:
begin
history = Node.find(nodeid).old_nodes.reverse.collect do |old_node|
[old_node.timestamp.strftime("%d %b %Y, %H:%M:%S")] + change_user(old_node)
[old_node.timestamp.succ.strftime("%d %b %Y, %H:%M:%S")] + change_user(old_node)
end
return ['node', nodeid, history]
rescue ActiveRecord::RecordNotFound
@ -748,10 +751,11 @@ class AmfController < ApplicationController
def getpoi(id,timestamp) #:doc:
amf_handle_error("'getpoi' #{id}") do
id = id.to_i
n = Node.find(id)
v = n.version
unless timestamp == ''
n = OldNode.find(id, :conditions=>['timestamp=?',DateTime.strptime(timestamp, "%d %b %Y, %H:%M:%S")])
n = OldNode.find(:first, :conditions => ['id = ? AND timestamp <= ?', id, timestamp], :order => 'timestamp DESC')
end
if n
@ -937,7 +941,11 @@ class AmfController < ApplicationController
end
def sql_get_way_version(wayid)
ActiveRecord::Base.connection.select_one("SELECT version FROM current_ways WHERE id=#{wayid.to_i}")
ActiveRecord::Base.connection.select_one("SELECT version FROM current_ways WHERE id=#{wayid.to_i}")['version']
end
def sql_get_way_user(wayid)
ActiveRecord::Base.connection.select_one("SELECT user FROM current_ways,changesets WHERE current_ways.id=#{wayid.to_i} AND current_ways.changeset=changesets.id")['user']
end
end

View file

@ -54,7 +54,10 @@ class DiaryEntryController < ApplicationController
@diary_comment = @entry.diary_comments.build(params[:diary_comment])
@diary_comment.user = @user
if @diary_comment.save
Notifier::deliver_diary_comment_notification(@diary_comment)
if @diary_comment.user != @entry.user
Notifier::deliver_diary_comment_notification(@diary_comment)
end
redirect_to :controller => 'diary_entry', :action => 'view', :display_name => @entry.user.display_name, :id => @entry.id
else
render :action => 'view'

View file

@ -27,8 +27,9 @@ class MessageController < ApplicationController
end
else
if params[:title]
# ?title= is set when someone reponds to this user's diary entry
@title = params[:title]
# ?title= is set when someone reponds to this user's diary
# entry. Then we pre-fill out the subject and the <title>
@title = @subject = params[:title]
else
# The default /message/new/$user view
@title = t 'message.new.title'
@ -44,7 +45,7 @@ class MessageController < ApplicationController
def reply
message = Message.find(params[:message_id], :conditions => ["to_user_id = ? or from_user_id = ?", @user.id, @user.id ])
@body = "On #{message.sent_on} #{message.sender.display_name} wrote:\n\n#{message.body.gsub(/^/, '> ')}"
@title = "Re: #{message.title.sub(/^Re:\s*/, '')}"
@title = @subject = "Re: #{message.title.sub(/^Re:\s*/, '')}"
@to_user = User.find(message.from_user_id)
render :action => 'new'
rescue ActiveRecord::RecordNotFound
@ -104,3 +105,4 @@ class MessageController < ApplicationController
render :action => 'no_such_user', :status => :not_found
end
end

View file

@ -23,6 +23,7 @@ class SwfController < ApplicationController
xmax=params['xmax'].to_f;
ymin=params['ymin'].to_f;
ymax=params['ymax'].to_f;
start=params['start'].to_i;
# - Begin movie
@ -54,7 +55,7 @@ class SwfController < ApplicationController
" AND "+OSM.sql_for_area(ymin,xmin,ymax,xmax,"gps_points.")+
" AND (gps_points.timestamp IS NOT NULL) "+
"ORDER BY fileid DESC,ts "+
"LIMIT 10000"
"LIMIT 10000 OFFSET #{start}"
else
sql="SELECT latitude*0.0000001 AS lat,longitude*0.0000001 AS lon,gpx_id AS fileid,"+
" EXTRACT(EPOCH FROM timestamp) AS ts, gps_points.trackid AS trackid "+
@ -62,7 +63,7 @@ class SwfController < ApplicationController
"WHERE "+OSM.sql_for_area(ymin,xmin,ymax,xmax,"gps_points.")+
" AND (gps_points.timestamp IS NOT NULL) "+
"ORDER BY fileid DESC,ts "+
"LIMIT 10000"
"LIMIT 10000 OFFSET #{start}"
end
gpslist=ActiveRecord::Base.connection.select_all sql

View file

@ -20,15 +20,24 @@ class Trace < ActiveRecord::Base
end
def tagstring
return tags.collect {|tt| tt.tag}.join(" ")
return tags.collect {|tt| tt.tag}.join(", ")
end
def tagstring=(s)
self.tags = s.split().collect {|tag|
tt = Tracetag.new
tt.tag = tag
tt
}
if s.include?','
self.tags = s.split(/\s*,\s*/).collect {|tag|
tt = Tracetag.new
tt.tag = tag
tt
}
else
#do as before for backwards compatibility:
self.tags = s.split().collect {|tag|
tt = Tracetag.new
tt.tag = tag
tt
}
end
end
def large_picture= (data)

View file

@ -11,9 +11,8 @@
<%= render :partial => "relation_details", :object => relation %>
<hr />
<% end %>
<%= link_to "Download XML", :controller => "old_relation", :action => "history" %>
or
<%= link_to "view details", :action => "relation" %>
<%= t'browse.relation_history.download', :download_xml_link => link_to(t('browse.relation_history.download_xml'), :controller => "old_relation", :action => "history"),
:view_details_link => link_to(t('browse.relation_history.view_details'), :action => "relation") %>
</td>
<%= render :partial => "map", :object => @relation %>
</tr>

View file

@ -114,10 +114,6 @@
<%= yield :left_menu %>
</div>
<div id="sotm" class="notice">
<%= link_to image_tag("sotm.png", :alt => t('layouts.sotm'), :title => t('layouts.sotm'), :border => "0"), "http://www.stateofthemap.org/register" %>
</div>
<%= yield :optionals %>
<center>

View file

@ -6,7 +6,7 @@
<table>
<tr valign="top">
<th><%= t'message.new.subject' %></th>
<td><%= f.text_field :title, :size => 60, :value => @title %></td>
<td><%= f.text_field :title, :size => 60, :value => @subject %></td>
</tr>
<tr valign="top">
<th><%= t'message.new.body' %></th>

View file

@ -27,9 +27,7 @@
<%= t'trace.trace.by' %> <%=link_to h(trace.user.display_name), {:controller => 'user', :action => 'view', :display_name => trace.user.display_name} %>
<% if !trace.tags.empty? %>
<%= t'trace.trace.in' %>
<% trace.tags.each do |tag| %>
<%= link_to_tag tag.tag %>
<% end %>
<%= trace.tags.collect { |tag| link_to_tag tag.tag }.join(", ") %>
<% end %>
</td>
</tr>

View file

@ -2,7 +2,7 @@
<table>
<tr><td align="right"><%= t'trace.trace_form.upload_gpx' %></td><td><%= f.file_field :gpx_file, :size => 50, :maxlength => 255 %></td></tr>
<tr><td align="right"><%= t'trace.trace_form.description' %></td><td><%= f.text_field :description, :size => 50, :maxlength => 255 %></td></tr>
<tr><td align="right"><%= t'trace.trace_form.tags' %></td><td><%= f.text_field :tagstring, :size => 50, :maxlength => 255 %></td></tr>
<tr><td align="right"><%= t'trace.trace_form.tags' %></td><td><%= f.text_field :tagstring, :size => 50, :maxlength => 255 %> (<%= t'trace.trace_form.tags_help' %>)</td></tr>
<tr><td align="right"><%= t'trace.trace_form.public' %></td><td><%= f.check_box :public %> <span class="minorNote">(<a href="<%= t'trace.trace_form.public_help_url' %>"><%= t'trace.trace_form.public_help' %></a>)</span></td></tr>
<tr><td></td><td><%= submit_tag t('trace.trace_form.upload_button') %> | <a href="<%= t'trace.trace_form.help_url' %>"><%= t'trace.trace_form.help' %></a></td></tr>
</table>

View file

@ -28,11 +28,11 @@
</tr>
<tr>
<td><%= t'trace.edit.description' %></td>
<td><%= f.text_field :description %></td>
<td><%= f.text_field :description, :size => 50 %></td>
</tr>
<tr>
<td><%= t'trace.edit.tags' %></td>
<td><%= f.text_field :tagstring %></td>
<td><%= f.text_field :tagstring, :size => 50 %> (<%= t'trace.edit.tags_help' %>)</td>
</tr>
</table>

View file

@ -36,9 +36,7 @@
<td><%= t'trace.view.tags' %></td>
<td>
<% unless @trace.tags.empty? %>
<% @trace.tags.each do |tag| %>
<%= link_to tag.tag, { :controller => 'trace', :action => 'list', :tag => tag.tag, :id => nil } %>
<% end %>
<%= @trace.tags.collect { |tag| link_to tag.tag, { :controller => 'trace', :action => 'list', :tag => tag.tag, :id => nil } }.join(", ") %>
<% else %>
<i><%= t'trace.view.none' %></i>
<% end %>