Mass rename of "bugs" as "notes" for increased user friendliness

This commit is contained in:
Tom Hughes 2011-05-21 17:22:31 +01:00
parent bb490aca81
commit e3b8b89330
42 changed files with 448 additions and 395 deletions

View file

@ -80,11 +80,11 @@ class BrowseController < ApplicationController
render :action => "not_found", :status => :not_found
end
def bug
@type = "bug"
@bug = MapBug.find(params[:id])
@next = MapBug.find(:first, :order => "id ASC", :conditions => [ "status != 'hidden' AND id > :id", { :id => @bug.id }] )
@prev = MapBug.find(:first, :order => "id DESC", :conditions => [ "status != 'hidden' AND id < :id", { :id => @bug.id }] )
def note
@type = "note"
@note = Note.find(params[:id])
@next = Note.find(:first, :order => "id ASC", :conditions => [ "status != 'hidden' AND id > :id", { :id => @note.id }] )
@prev = Note.find(:first, :order => "id DESC", :conditions => [ "status != 'hidden' AND id < :id", { :id => @note.id }] )
rescue ActiveRecord::RecordNotFound
render :action => "not_found", :status => :not_found
end

View file

@ -1,4 +1,4 @@
class MapBugsController < ApplicationController
class NoteController < ApplicationController
layout 'site', :only => [:mine]
@ -36,17 +36,17 @@ class MapBugsController < ApplicationController
limit = getLimit
conditions = closedCondition
check_boundaries(@min_lon, @min_lat, @max_lon, @max_lat, MAX_BUG_REQUEST_AREA)
check_boundaries(@min_lon, @min_lat, @max_lon, @max_lat, MAX_NOTE_REQUEST_AREA)
@bugs = MapBug.find_by_area(@min_lat, @min_lon, @max_lat, @max_lon, :include => :comments, :order => "updated_at DESC", :limit => limit, :conditions => conditions)
@notes = Note.find_by_area(@min_lat, @min_lon, @max_lat, @max_lon, :include => :comments, :order => "updated_at DESC", :limit => limit, :conditions => conditions)
respond_to do |format|
format.html {render :template => 'map_bugs/list.rjs', :content_type => "text/javascript"}
format.rss {render :template => 'map_bugs/list.rss'}
format.html {render :template => 'note/list.rjs', :content_type => "text/javascript"}
format.rss {render :template => 'note/list.rss'}
format.js
format.xml {render :template => 'map_bugs/list.xml'}
format.json { render :json => @bugs.to_json(:methods => [:lat, :lon], :only => [:id, :status, :created_at], :include => { :comments => { :only => [:author_name, :created_at, :body]}}) }
format.gpx {render :template => 'map_bugs/list.gpx'}
format.xml {render :template => 'note/list.xml'}
format.json { render :json => @notes.to_json(:methods => [:lat, :lon], :only => [:id, :status, :created_at], :include => { :comments => { :only => [:author_name, :created_at, :body]}}) }
format.gpx {render :template => 'note/list.gpx'}
end
end
@ -62,9 +62,9 @@ class MapBugsController < ApplicationController
name = "NoName"
name = params['name'] if params['name']
#Include in a transaction to ensure that there is always a map_bug_comment for every map_bug
MapBug.transaction do
@bug = MapBug.create_bug(lat, lon)
#Include in a transaction to ensure that there is always a note_comment for every note
Note.transaction do
@note = Note.create_bug(lat, lon)
#TODO: move this into a helper function
begin
@ -72,17 +72,17 @@ class MapBugsController < ApplicationController
response = REXML::Document.new(Net::HTTP.get(URI.parse(url)))
if result = response.get_text("reversegeocode/result")
@bug.nearby_place = result.to_s
@note.nearby_place = result.to_s
else
@bug.nearby_place = "unknown"
@note.nearby_place = "unknown"
end
rescue Exception => err
@bug.nearby_place = "unknown"
@note.nearby_place = "unknown"
end
@bug.save
@note.save
add_comment(@bug, comment, name, "opened")
add_comment(@note, comment, name, "opened")
end
render_ok
@ -97,12 +97,12 @@ class MapBugsController < ApplicationController
id = params['id'].to_i
bug = MapBug.find_by_id(id)
raise OSM::APINotFoundError unless bug
raise OSM::APIAlreadyDeletedError unless bug.visible
note = Note.find(id)
raise OSM::APINotFoundError unless note
raise OSM::APIAlreadyDeletedError unless note.visible
MapBug.transaction do
bug_comment = add_comment(bug, params['text'], name, "commented")
Note.transaction do
add_comment(note, params['text'], name, "commented")
end
render_ok
@ -115,13 +115,13 @@ class MapBugsController < ApplicationController
name = "NoName"
name = params['name'] if params['name']
bug = MapBug.find_by_id(id)
raise OSM::APINotFoundError unless bug
raise OSM::APIAlreadyDeletedError unless bug.visible
note = Note.find_by_id(id)
raise OSM::APINotFoundError unless note
raise OSM::APIAlreadyDeletedError unless note.visible
MapBug.transaction do
bug.close_bug
add_comment(bug, :nil, name, "closed")
Note.transaction do
note.close
add_comment(note, :nil, name, "closed")
end
render_ok
@ -138,37 +138,37 @@ class MapBugsController < ApplicationController
bbox = bbox.split(',')
@min_lon, @min_lat, @max_lon, @max_lat = sanitise_boundaries(bbox)
check_boundaries(@min_lon, @min_lat, @max_lon, @max_lat, MAX_BUG_REQUEST_AREA)
check_boundaries(@min_lon, @min_lat, @max_lon, @max_lat, MAX_NOTE_REQUEST_AREA)
conditions = cond_merge conditions, [OSM.sql_for_area(@min_lat, @min_lon, @max_lat, @max_lon)]
end
@comments = MapBugComment.find(:all, :limit => limit, :order => "created_at DESC", :joins => :map_bug, :include => :map_bug, :conditions => conditions)
render :template => 'map_bugs/rss.rss'
@comments = NoteComment.find(:all, :limit => limit, :order => "created_at DESC", :joins => :note, :include => :note, :conditions => conditions)
render :template => 'note/rss.rss'
end
def read
@bug = MapBug.find(params['id'])
raise OSM::APINotFoundError unless @bug
raise OSM::APIAlreadyDeletedError unless @bug.visible
@note = Note.find(params['id'])
raise OSM::APINotFoundError unless @note
raise OSM::APIAlreadyDeletedError unless @note.visible
respond_to do |format|
format.rss
format.xml
format.json { render :json => @bug.to_json(:methods => [:lat, :lon], :only => [:id, :status, :created_at], :include => { :comments => { :only => [:author_name, :created_at, :body]}}) }
format.json { render :json => @note.to_json(:methods => [:lat, :lon], :only => [:id, :status, :created_at], :include => { :comments => { :only => [:author_name, :created_at, :body]}}) }
format.gpx
end
end
def delete
bug = MapBug.find(params['id'])
raise OSM::APINotFoundError unless @bug
raise OSM::APIAlreadyDeletedError unless @bug.visible
note = note.find(params['id'])
raise OSM::APINotFoundError unless note
raise OSM::APIAlreadyDeletedError unless note.visible
MapBug.transaction do
bug.status = "hidden"
bug.save
add_comment(bug,:nil,name,"hidden")
Note.transaction do
note.status = "hidden"
note.save
add_comment(note, :nil, name, "hidden")
end
render :text => "ok\n", :content_type => "text/html"
@ -178,20 +178,18 @@ class MapBugsController < ApplicationController
raise OSM::APIBadUserInput.new("No query string was given") unless params['q']
limit = getLimit
conditions = closedCondition
conditions = cond_merge conditions, ['map_bug_comment.body ~ ?', params['q']]
conditions = cond_merge conditions, ['note_comments.body ~ ?', params['q']]
#TODO: There should be a better way to do this. CloseConditions are ignored at the moment
bugs2 = MapBug.find(:all, :limit => limit, :order => "updated_at DESC", :joins => :comments, :include => :comments,
:conditions => conditions)
@bugs = bugs2.uniq
@notes = Note.find(:all, :limit => limit, :order => "updated_at DESC", :joins => :comments, :include => :comments, :conditions => conditions).uniq
respond_to do |format|
format.html {render :template => 'map_bugs/list.rjs', :content_type => "text/javascript"}
format.rss {render :template => 'map_bugs/list.rss'}
format.html {render :template => 'note/list.rjs', :content_type => "text/javascript"}
format.rss {render :template => 'note/list.rss'}
format.js
format.xml {render :template => 'map_bugs/list.xml'}
format.json { render :json => @bugs.to_json(:methods => [:lat, :lon], :only => [:id, :status, :created_at], :include => { :comments => { :only => [:author_name, :created_at, :body]}}) }
format.gpx {render :template => 'map_bugs/list.gpx'}
format.xml {render :template => 'note/list.xml'}
format.json { render :json => @notes.to_json(:methods => [:lat, :lon], :only => [:id, :status, :created_at], :include => { :comments => { :only => [:author_name, :created_at, :body]}}) }
format.gpx {render :template => 'note/list.gpx'}
end
end
@ -201,7 +199,7 @@ class MapBugsController < ApplicationController
if @user2
if @user2.data_public? or @user2 == @user
conditions = ['map_bug_comment.author_id = ?', @user2.id]
conditions = ['note_comments.author_id = ?', @user2.id]
else
conditions = ['false']
end
@ -217,20 +215,20 @@ class MapBugsController < ApplicationController
user_link = render_to_string :partial => "user", :object => @user2
end
@title = t 'bugs.user.title_user', :user => @user2.display_name
@heading = t 'bugs.user.heading_user', :user => @user2.display_name
@description = t 'bugs.user.description_user', :user => user_link
@title = t 'note.mine.title', :user => @user2.display_name
@heading = t 'note.mine.heading', :user => @user2.display_name
@description = t 'note.mine.description', :user => user_link
@page = (params[:page] || 1).to_i
@page_size = 10
@bugs = MapBug.find(:all,
:include => [:comments, {:comments => :author}],
:joins => :comments,
:order => "updated_at DESC",
:conditions => conditions,
:offset => (@page - 1) * @page_size,
:limit => @page_size).uniq
@notes = Note.find(:all,
:include => [:comments, {:comments => :author}],
:joins => :comments,
:order => "updated_at DESC",
:conditions => conditions,
:offset => (@page - 1) * @page_size,
:limit => @page_size).uniq
end
private
@ -260,8 +258,8 @@ private
if output_js == :true
render :text => "osbResponse();", :content_type => "text/javascript"
else
render :text => "ok " + @bug.id.to_s + "\n", :content_type => "text/html" if @bug
render :text => "ok\n", :content_type => "text/html" unless @bug
render :text => "ok " + @note.id.to_s + "\n", :content_type => "text/html" if @note
render :text => "ok\n", :content_type => "text/html" unless @note
end
end
@ -286,24 +284,24 @@ private
return conditions
end
def add_comment(bug, comment, name,event)
bug_comment = bug.comments.create(:visible => true, :event => event)
bug_comment.body = comment unless comment == :nil
def add_comment(note, text, name, event)
comment = note.comments.create(:visible => true, :event => event)
comment.body = text unless text == :nil
if @user
bug_comment.author_id = @user.id
bug_comment.author_name = @user.display_name
comment.author_id = @user.id
comment.author_name = @user.display_name
else
bug_comment.author_ip = request.remote_ip
bug_comment.author_name = name + " (a)"
comment.author_ip = request.remote_ip
comment.author_name = name + " (a)"
end
bug_comment.save
bug.save
comment.save
note.save
sent_to = Set.new
bug.comments.each do | cmt |
note.comments.each do | cmt |
if cmt.author
unless sent_to.include?(cmt.author)
Notifier.deliver_bug_comment_notification(bug_comment, cmt.author) unless cmt.author == @user
Notifier.deliver_note_comment_notification(note_comment, cmt.author) unless cmt.author == @user
sent_to.add(cmt.author)
end
end

View file

@ -1,8 +1,8 @@
class MapBug < ActiveRecord::Base
class Note < ActiveRecord::Base
include GeoRecord
has_many :comments, :class_name => "MapBugComment",
:foreign_key => :bug_id,
has_many :comments, :class_name => "NoteComment",
:foreign_key => :note_id,
:order => :created_at,
:conditions => "visible = true AND body IS NOT NULL"
@ -14,13 +14,13 @@ class MapBug < ActiveRecord::Base
validates_inclusion_of :status, :in => ["open", "closed", "hidden"]
def self.create_bug(lat, lon)
bug = MapBug.new(:lat => lat, :lon => lon, :status => "open")
raise OSM::APIBadUserInput.new("The node is outside this world") unless bug.in_world?
note = Note.new(:lat => lat, :lon => lon, :status => "open")
raise OSM::APIBadUserInput.new("The note is outside this world") unless note.in_world?
return bug
return note
end
def close_bug
def close
self.status = "closed"
self.closed_at = Time.now.getutc

View file

@ -1,7 +1,5 @@
class MapBugComment < ActiveRecord::Base
set_table_name 'map_bug_comment'
belongs_to :map_bug, :foreign_key => :bug_id
class NoteComment < ActiveRecord::Base
belongs_to :note, :foreign_key => :bug_id
belongs_to :author, :class_name => "User", :foreign_key => :author_id
validates_inclusion_of :event, :in => [ "opened", "closed", "reopened", "commented", "hidden" ]

View file

@ -95,20 +95,20 @@ class Notifier < ActionMailer::Base
body :friend => friend
end
def bug_comment_notification(bug_comment, recipient)
def note_comment_notification(comment, recipient)
common_headers recipient
owner = (recipient == bug_comment.map_bug.author);
subject I18n.t('notifier.map_bug_plain.subject_own', :commenter => bug_comment.author_name) if owner
subject I18n.t('notifier.map_bug_plain.subject_other', :commenter => bug_comment.author_name) unless owner
owner = (recipient == comment.note.author);
subject I18n.t('notifier.note_plain.subject_own', :commenter => comment.author_name) if owner
subject I18n.t('notifier.note_plain.subject_other', :commenter => comment.author_name) unless owner
body :bugurl => url_for(:host => SERVER_URL,
:controller => "browse",
:action => "bug",
:id => bug_comment.bug_id),
:place => bug_comment.map_bug.nearby_place,
:comment => bug_comment.body,
body :nodeurl => url_for(:host => SERVER_URL,
:controller => "browse",
:action => "note",
:id => comment.note_id),
:place => comment.note.nearby_place,
:comment => comment.body,
:owner => owner,
:commenter => bug_comment.author_name
:commenter => comment.author_name
end
private

View file

@ -38,7 +38,7 @@
$("area_larger_map").href = '/?minlon='+minlon+'&minlat='+minlat+'&maxlon='+maxlon+'&maxlat='+maxlat+'&box=yes';
$("area_larger_map").innerHTML = "<%= t 'browse.map.larger.area' %>";
<% elsif map.instance_of? MapBug %>
<% elsif map.instance_of? Note %>
var centre = new OpenLayers.LonLat(<%= map.lon %>, <%= map.lat %>);
setMapCenter(centre, 16);

View file

@ -1,83 +0,0 @@
<table width="100%">
<tr>
<td width="100%">
<h2>
<% if @bug.status == "closed" %>
<%= image_tag("closed_bug_marker.png", :alt => 'closed') %>
<%= t 'browse.bug.closed_title', :bug_name => @bug.id %>
<% else %>
<%= image_tag("open_bug_marker.png", :alt => 'open') %>
<%= t 'browse.bug.open_title', :bug_name => @bug.id %>
<% end %>
</h2>
</td>
<td>
<%= render :partial => "navigation" %>
</td>
</tr>
<tr valign="top">
<td>
<table>
<tr>
<th><%= t 'browse.bug.created_at' %></th>
<td><%= l @bug.created_at %></td>
</tr>
<tr>
<th><%= t 'browse.bug.edited_at' %></th>
<td><%= l @bug.updated_at %></td>
</tr>
<% if @bug.status == "closed" %>
<tr>
<th><%= t 'browse.bug.closed_at' %></th>
<td><%= l @bug.closed_at %></td>
</tr>
<% end %>
<tr>
<th><%= t 'browse.bug.opened_by' %></th>
<% if @bug.author.nil? %>
<td> <%= @bug.author_name %> </td>
<% else %>
<td><%= link_to h(@bug.author_name), :controller => "user", :action => "view", :display_name => @bug.author_name %></td>
<% end %>
</tr>
<tr>
<th><%= t 'browse.bug.description' %></th>
<td><%= h(@bug.comments.first.body) %></td>
</tr>
<tr>
<th><%= t 'browse.node_details.coordinates' %></th>
<td><div class="geo"><%= link_to ("<span class='latitude'>#{number_with_delimiter(@bug.lat)}</span>, <span class='longitude'>#{number_with_delimiter(@bug.lon)}</span>"), {:controller => 'site', :action => 'index', :lat => h(@bug.lat), :lon => h(@bug.lon), :zoom => "18"} %></div></td>
</tr>
</table>
<br />
<% if @bug.comments.length > 1 %>
<table>
<tr>
<th width="20%"> <%= t 'browse.bug.comment_by' %></th>
<th width="60%"> <%= t 'browse.bug.comment' %></th>
<th width="20%"> <%= t 'browse.bug.date' %></th>
</tr>
<% @bug.comments[1..-1].each do |bug_comment| %>
<tr>
<td>
<% if bug_comment.user.nil? %>
<%= bug_comment.author_name %>
<% else %>
<%= link_to h(bug_comment.user.display_name), :controller => "user", :action => "view", :display_name => bug_comment.user.display_name %>
<% end %>
</td>
<td> <%= h(bug_comment.body) %> </td>
<td> <%= l bug_comment.created_at %> </td>
</tr>
<% end %>
</table>
<% end %>
<hr />
</td>
<%= render :partial => "map", :object => @bug %>
</tr>
</table>

View file

@ -0,0 +1,83 @@
<table width="100%">
<tr>
<td width="100%">
<h2>
<% if @note.status == "closed" %>
<%= image_tag("closed_note_marker.png", :alt => 'closed') %>
<%= t 'browse.note.closed_title', :note_name => @note.id %>
<% else %>
<%= image_tag("open_note_marker.png", :alt => 'open') %>
<%= t 'browse.note.open_title', :note_name => @note.id %>
<% end %>
</h2>
</td>
<td>
<%= render :partial => "navigation" %>
</td>
</tr>
<tr valign="top">
<td>
<table>
<tr>
<th><%= t 'browse.note.created_at' %></th>
<td><%= l @note.created_at %></td>
</tr>
<tr>
<th><%= t 'browse.note.edited_at' %></th>
<td><%= l @note.updated_at %></td>
</tr>
<% if @note.status == "closed" %>
<tr>
<th><%= t 'browse.note.closed_at' %></th>
<td><%= l @note.closed_at %></td>
</tr>
<% end %>
<tr>
<th><%= t 'browse.note.opened_by' %></th>
<% if @note.author.nil? %>
<td> <%= @note.author_name %> </td>
<% else %>
<td><%= link_to h(@note.author_name), :controller => "user", :action => "view", :display_name => @note.author_name %></td>
<% end %>
</tr>
<tr>
<th><%= t 'browse.note.description' %></th>
<td><%= h(@note.comments.first.body) %></td>
</tr>
<tr>
<th><%= t 'browse.node_details.coordinates' %></th>
<td><div class="geo"><%= link_to ("<span class='latitude'>#{number_with_delimiter(@note.lat)}</span>, <span class='longitude'>#{number_with_delimiter(@note.lon)}</span>"), {:controller => 'site', :action => 'index', :lat => h(@note.lat), :lon => h(@note.lon), :zoom => "18"} %></div></td>
</tr>
</table>
<br />
<% if @note.comments.length > 1 %>
<table>
<tr>
<th width="20%"> <%= t 'browse.note.comment_by' %></th>
<th width="60%"> <%= t 'browse.note.comment' %></th>
<th width="20%"> <%= t 'browse.note.date' %></th>
</tr>
<% @note.comments[1..-1].each do |comment| %>
<tr>
<td>
<% if comment.author.nil? %>
<%= comment.author_name %>
<% else %>
<%= link_to h(comment.author.display_name), :controller => "user", :action => "view", :display_name => comment.author.display_name %>
<% end %>
</td>
<td> <%= h(comment.body) %> </td>
<td> <%= l comment.created_at %> </td>
</tr>
<% end %>
</table>
<% end %>
<hr />
</td>
<%= render :partial => "map", :object => @note %>
</tr>
</table>

View file

@ -1,15 +0,0 @@
xml.wpt("lon" => bug.lon, "lat" => bug.lat) do
xml.desc do
xml.cdata! bug.flatten_comment("<hr />")
end
xml.extension do
if bug.status = "open"
xml.closed "0"
else
xml.closed "1"
end
xml.id bug.id
end
end

View file

@ -1,18 +0,0 @@
xml.item do
if bug.status == "closed"
xml.title t('bugs.rss.closed', :place => bug.nearby_place)
elsif bug.comments.length > 1
xml.title t('bugs.rss.comment', :place => bug.nearby_place)
else
xml.title t('bugs.rss.new', :place => bug.nearby_place)
end
xml.link url_for(:controller => "browse", :action => "bug", :id => bug.id, :only_path => false)
xml.guid url_for(:controller => "map_bugs", :action => "read", :id => bug.id, :only_path => false)
xml.description htmlize(bug.flatten_comment("<br><br>"))
xml.author bug.author_name
xml.pubDate bug.updated_at.to_s(:rfc822)
xml.geo :lat, bug.lat
xml.geo :long, bug.lon
xml.georss :point, "#{bug.lat} #{bug.lon}"
end

View file

@ -1,21 +0,0 @@
xml.bug("lon" => bug.lon, "lat" => bug.lat) do
xml.id bug.id
xml.date_created bug.created_at
xml.nearby bug.nearby_place
xml.status bug.status
if bug.status == "closed"
xml.date_closed bug.closed_at
end
xml.comments do
bug.comments.each do |comment|
xml.comment do
xml.date comment.created_at
xml.uid comment.author_id unless comment.author_id.nil?
xml.user comment.author_name
xml.text comment.body
end
end
end
end

View file

@ -1,6 +0,0 @@
@bugs.each do |bug|
page.call "putAJAXMarker",
bug.id, bug.lon, bug.lat,
bug.flatten_comment("<hr />"),
bug.status == "open" ? 0 : 1
end

View file

@ -1,3 +0,0 @@
xml.instruct!
xml << render(:partial => "bug", :collection => @bugs)

View file

@ -1,37 +0,0 @@
<h1><%= @heading %></h1>
<p><%= @description %></p>
<%= render :partial => 'bugs_paging_nav' %>
<table id="bug_list" cellpadding="3">
<tr>
<th></th>
<th><%= t'bugs.user.id' %></th>
<th><%= t'changeset.changesets.user' %></th>
<th><%= t'changeset.changesets.comment' %></th>
<th><%= t'changeset.changesets.saved_at' %></th>
<th><%= t'bugs.user.last_changed' %></th>
</tr>
<% @bugs.each do |bug| %>
<tr<% if bug.author != @user2 %> bgcolor="#EEEEEE"<% end %>>
<td>
<% if bug.status == "closed" %>
<%= image_tag("closed_bug_marker.png", :alt => 'closed') %>
<% else %>
<%= image_tag("open_bug_marker.png", :alt => 'open') %>
<% end %>
</td>
<td><%= link_to bug.id.to_s, :controller => "browse", :action => "bug", :id => bug.id %></td>
<% if bug.author.nil? %>
<td> <%= bug.author_name %> </td>
<% else %>
<td><%= link_to h(bug.author_name), :controller => "user", :action => "view", :display_name => bug.author_name %></td>
<% end %>
<td> <%= htmlize bug.comments.first.body %> </td>
<td><%= l bug.created_at %></td>
<td><%= l bug.updated_at %></td>
</tr>
<% end %>
</table>
<%= render :partial => 'bugs_paging_nav' %>

View file

@ -1,3 +0,0 @@
xml.instruct!
xml << render(:partial => "bug", :object => @bug)

View file

@ -0,0 +1,15 @@
xml.wpt("lon" => note.lon, "lat" => note.lat) do
xml.desc do
xml.cdata! note.flatten_comment("<hr />")
end
xml.extension do
if note.status = "open"
xml.closed "0"
else
xml.closed "1"
end
xml.id note.id
end
end

View file

@ -0,0 +1,18 @@
xml.item do
if note.status == "closed"
xml.title t('note.rss.closed', :place => note.nearby_place)
elsif note.comments.length > 1
xml.title t('note.rss.comment', :place => note.nearby_place)
else
xml.title t('note.rss.new', :place => note.nearby_place)
end
xml.link url_for(:controller => "browse", :action => "note", :id => note.id, :only_path => false)
xml.guid url_for(:controller => "note", :action => "read", :id => note.id, :only_path => false)
xml.description htmlize(note.flatten_comment("<br><br>"))
xml.author note.author_name
xml.pubDate note.updated_at.to_s(:rfc822)
xml.geo :lat, note.lat
xml.geo :long, note.lon
xml.georss :point, "#{note.lat} #{note.lon}"
end

View file

@ -0,0 +1,21 @@
xml.note("lon" => note.lon, "lat" => note.lat) do
xml.id note.id
xml.date_created note.created_at
xml.nearby note.nearby_place
xml.status note.status
if note.status == "closed"
xml.date_closed note.closed_at
end
xml.comments do
note.comments.each do |comment|
xml.comment do
xml.date comment.created_at
xml.uid comment.author_id unless comment.author_id.nil?
xml.user comment.author_name
xml.text comment.body
end
end
end
end

View file

@ -8,7 +8,7 @@
| <%= t('changeset.changeset_paging_nav.showing_page', :page => @page) %> |
<% if @bugs.size < @page_size %>
<% if @notes.size < @page_size %>
<%= t('changeset.changeset_paging_nav.next') %>
<% else %>
<%= link_to t('changeset.changeset_paging_nav.next'), params.merge({ :page => @page + 1 }) %>

View file

@ -3,5 +3,5 @@ xml.instruct!
xml.gpx("version" => "1.1",
"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
"xsi:schemaLocation" => "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd") do
xml << render(:partial => "bug", :collection => @bugs)
xml << render(:partial => "note", :collection => @notes)
end

6
app/views/note/list.rjs Normal file
View file

@ -0,0 +1,6 @@
@notes.each do |note|
page.call "putAJAXMarker",
note.id, note.lon, note.lat,
note.flatten_comment("<hr />"),
note.status == "open" ? 0 : 1
end

View file

@ -4,10 +4,10 @@ xml.rss("version" => "2.0",
"xmlns:geo" => "http://www.w3.org/2003/01/geo/wgs84_pos#",
"xmlns:georss" => "http://www.georss.org/georss") do
xml.channel do
xml.title "OpenStreetBugs"
xml.description t('bugs.rss.description_area', :min_lat => @min_lat, :min_lon => @min_lon, :max_lat => @max_lat, :max_lon => @max_lon )
xml.title t('note.rss.title')
xml.description t('note.rss.description_area', :min_lat => @min_lat, :min_lon => @min_lon, :max_lat => @max_lat, :max_lon => @max_lon )
xml.link url_for(:controller => "site", :action => "index", :only_path => false)
xml << render(:partial => "bug", :collection => @bugs)
xml << render(:partial => "note", :collection => @notes)
end
end

View file

@ -0,0 +1,3 @@
xml.instruct!
xml << render(:partial => "note", :collection => @notes)

View file

@ -0,0 +1,37 @@
<h1><%= @heading %></h1>
<p><%= @description %></p>
<%= render :partial => 'notes_paging_nav' %>
<table id="note_list" cellpadding="3">
<tr>
<th></th>
<th><%= t'note.mine.id' %></th>
<th><%= t'changeset.changesets.user' %></th>
<th><%= t'changeset.changesets.comment' %></th>
<th><%= t'changeset.changesets.saved_at' %></th>
<th><%= t'note.mine.last_changed' %></th>
</tr>
<% @notes.each do |note| %>
<tr<% if note.author != @user2 %> bgcolor="#EEEEEE"<% end %>>
<td>
<% if note.status == "closed" %>
<%= image_tag("closed_note_marker.png", :alt => 'closed') %>
<% else %>
<%= image_tag("open_note_marker.png", :alt => 'open') %>
<% end %>
</td>
<td><%= link_to note.id.to_s, :controller => "browse", :action => "note", :id => note.id %></td>
<% if note.author.nil? %>
<td> <%= note.author_name %> </td>
<% else %>
<td><%= link_to h(note.author_name), :controller => "user", :action => "view", :display_name => note.author_name %></td>
<% end %>
<td> <%= htmlize note.comments.first.body %> </td>
<td><%= l note.created_at %></td>
<td><%= l note.updated_at %></td>
</tr>
<% end %>
</table>
<%= render :partial => 'notes_paging_nav' %>

View file

@ -3,5 +3,5 @@ xml.instruct!
xml.gpx("version" => "1.1",
"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
"xsi:schemaLocation" => "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd") do
xml << render(:partial => "bug", :object => @bug)
xml << render(:partial => "note", :object => @note)
end

View file

@ -4,10 +4,10 @@ xml.rss("version" => "2.0",
"xmlns:geo" => "http://www.w3.org/2003/01/geo/wgs84_pos#",
"xmlns:georss" => "http://www.georss.org/georss") do
xml.channel do
xml.title "OpenStreetBugs"
xml.description t('bugs.rss.description_item', :id => @bug.id)
xml.title t('note.rss.title')
xml.description t('note.rss.description_item', :id => @note.id)
xml.link url_for(:controller => "site", :action => "index", :only_path => false)
xml << render(:partial => "bug", :object => @bug)
xml << render(:partial => "note", :object => @note)
end
end

View file

@ -0,0 +1,3 @@
xml.instruct!
xml << render(:partial => "note", :object => @note)

View file

@ -4,24 +4,24 @@ xml.rss("version" => "2.0",
"xmlns:geo" => "http://www.w3.org/2003/01/geo/wgs84_pos#",
"xmlns:georss" => "http://www.georss.org/georss") do
xml.channel do
xml.title "OpenStreetBugs"
xml.description t('bugs.rss.description_area', :min_lat => @min_lat, :min_lon => @min_lon, :max_lat => @max_lat, :max_lon => @max_lon )
xml.title t('note.rss.title')
xml.description t('note.rss.description_area', :min_lat => @min_lat, :min_lon => @min_lon, :max_lat => @max_lat, :max_lon => @max_lon )
xml.link url_for(:controller => "site", :action => "index", :only_path => false)
@comments.each do |comment|
xml.item do
if comment.event == "closed"
xml.title t('bugs.rss.closed', :place => comment.map_bug.nearby_place)
xml.title t('note.rss.closed', :place => comment.note.nearby_place)
elsif comment.event == "commented"
xml.title t('bugs.rss.comment', :place => comment.map_bug.nearby_place)
xml.title t('note.rss.comment', :place => comment.note.nearby_place)
elsif comment.event == "opened"
xml.title t('bugs.rss.new', :place => comment.map_bug.nearby_place)
xml.title t('note.rss.new', :place => comment.note.nearby_place)
else
xml.title "unknown event"
end
xml.link url_for(:controller => "browse", :action => "bug", :id => comment.map_bug.id, :only_path => false)
xml.guid url_for(:controller => "browse", :action => "bug", :id => comment.map_bug.id, :only_path => false)
xml.link url_for(:controller => "browse", :action => "note", :id => comment.note.id, :only_path => false)
xml.guid url_for(:controller => "browse", :action => "note", :id => comment.note.id, :only_path => false)
description_text = ""
@ -31,15 +31,15 @@ xml.rss("version" => "2.0",
description_text += "<br>"
end
description_text += "<b>Full bug report:</b><br>"
description_text += comment.map_bug.flatten_comment("<br>", comment.created_at)
description_text += "<b>Full note:</b><br>"
description_text += comment.note.flatten_comment("<br>", comment.created_at)
xml.description description_text
xml.author comment.author_name
xml.pubDate comment.created_at.to_s(:rfc822)
xml.geo :lat, comment.map_bug.lat
xml.geo :long, comment.map_bug.lon
xml.georss :point, "#{comment.map_bug.lat} #{comment.map_bug.lon}"
xml.geo :lat, comment.note.lat
xml.geo :long, comment.note.lon
xml.georss :point, "#{comment.note.lat} #{comment.note.lon}"
end
end
end

View file

@ -1,15 +0,0 @@
<%= t 'notifier.map_bug_plain.greeting' %>
<% if @owner %>
<%= t 'notifier.map_bug_plain.your_bug', :commenter => @commenter, :place => @place %>
<% else %>
<%= t 'notifier.map_bug_plain.commented_bug', :commenter => @commenter, :place => @place %>
<% end %>
==
<%= @comment %>
==
<%= t 'notifier.map_bug_plain.details', :URL => @bugurl %>

View file

@ -0,0 +1,15 @@
<%= t 'notifier.note_plain.greeting' %>
<% if @owner %>
<%= t 'notifier.note_plain.your_note', :commenter => @commenter, :place => @place %>
<% else %>
<%= t 'notifier.note_plain.commented_note', :commenter => @commenter, :place => @place %>
<% end %>
==
<%= @comment %>
==
<%= t 'notifier.note_plain.details', :URL => @noteurl %>

View file

@ -139,10 +139,10 @@ end
map.dataLayer.events.register("visibilitychanged", map.dataLayer, toggleData);
map.addLayer(map.dataLayer);
map.osbLayer = new OpenLayers.Layer.OpenStreetBugs("OpenStreetBugs", {
map.osbLayer = new OpenLayers.Layer.OpenStreetBugs("Notes", {
serverURL: "/api/0.6/",
iconOpen: new OpenLayers.Icon("<%= image_path "open_bug_marker.png" %>", new OpenLayers.Size(22, 22), new OpenLayers.Pixel(-11, -11)),
iconClosed: new OpenLayers.Icon("<%= image_path "closed_bug_marker.png" %>", new OpenLayers.Size(22, 22), new OpenLayers.Pixel(-11, -11)),
iconOpen: new OpenLayers.Icon("<%= image_path "open_note_marker.png" %>", new OpenLayers.Size(22, 22), new OpenLayers.Pixel(-11, -11)),
iconClosed: new OpenLayers.Icon("<%= image_path "closed_noe_marker.png" %>", new OpenLayers.Size(22, 22), new OpenLayers.Pixel(-11, -11)),
readonly: false,
setCookie: false,
permalinkURL: "http://www.openstreetmap.org/",

View file

@ -23,9 +23,9 @@
|
<%= link_to t('user.view.my edits'), :controller => 'changeset', :action => 'list', :display_name => @user.display_name %>
|
<%= link_to t('user.view.my traces'), :controller => 'trace', :action=>'mine' %>
<%= link_to t('user.view.my traces'), :controller => 'trace', :action=> 'mine' %>
|
<%= link_to t('user.view.my bugs'), :controller => 'map_bugs', :action=>'my_bugs' %>
<%= link_to t('user.view.my notes'), :controller => 'note', :action=> 'mine' %>
|
<%= link_to t('user.view.my settings'), :controller => 'user', :action => 'account', :display_name => @user.display_name %>
|
@ -45,7 +45,7 @@
|
<%= link_to t('user.view.traces'), :controller => 'trace', :action => 'view', :display_name => @this_user.display_name %>
|
<%= link_to t('user.view.bugs'), :controller => 'map_bugs', :action=>'my_bugs' %>
<%= link_to t('user.view.notes'), :controller => 'note', :action=> 'mine' %>
|
<% if @user and @user.is_friends_with?(@this_user) %>
<%= link_to t('user.view.remove as friend'), :controller => 'user', :action => 'remove_friend', :display_name => @this_user.display_name %>

View file

@ -24,8 +24,8 @@ standard_settings: &standard_settings
max_number_of_nodes: 50000
# Maximum number of nodes that can be in a way (checked on save)
max_number_of_way_nodes: 2000
# The maximum area you're allowed to request bugs from, in square degrees
max_bug_request_area: 25
# The maximum area you're allowed to request notes from, in square degrees
max_note_request_area: 25
# Zoom level to use for postcode results from the geocoder
postcode_zoom: 15
# Zoom level to use for geonames results from the geocoder

View file

@ -277,9 +277,9 @@ en:
download_xml: "Download XML"
view_history: "view history"
edit: "edit"
bug:
open_title: "Unresolved issue: {{bug_name}}"
closed_title: "Resolved issue: {{bug_name}}"
note:
open_title: "Unresolved issue: {{note_name}}"
closed_title: "Resolved issue: {{note_name}}"
created_at: "Created at:"
edited_at: "Edited at:"
closed_at: "Closed at:"
@ -1178,13 +1178,13 @@ en:
greeting: "Hi,"
hopefully_you: "Someone (possibly you) has asked for the password to be reset on this email address's openstreetmap.org account."
click_the_link: "If this is you, please click the link below to reset your password."
map_bug_plain:
subject_own: "[OpenStreetMap bugs] {{commenter}} has commented on one of your bugs"
subject_other: "[OpenStreetMap bugs] {{commenter}} has commented on a bug you are interested in"
note_plain:
subject_own: "[OpenStreetMap] {{commenter}} has commented on one of your notes"
subject_other: "[OpenStreetMap] {{commenter}} has commented on a note you are interested in"
greeting: "Hi,"
your_bug: "{{commenter}} has left a comment on one of your map bug reports near {{place}}."
commented_bug: "{{commenter}} has left a comment on a map bug report you have commented on. The bug is near {{place}}."
details: "More details about the bug report can be found at {{URL}}."
your_note: "{{commenter}} has left a comment on one of your map notes near {{place}}."
commented_note: "{{commenter}} has left a comment on a map note you have commented on. The note is near {{place}}."
details: "More details about the note can be found at {{URL}}."
message:
inbox:
title: "Inbox"
@ -1615,7 +1615,7 @@ en:
new diary entry: new diary entry
my edits: my edits
my traces: my traces
my bugs: my map bugs
my notes: my map notes
my settings: my settings
oauth settings: oauth settings
blocks on me: blocks on me
@ -1624,7 +1624,7 @@ en:
diary: diary
edits: edits
traces: traces
bugs: map bugs
notes: map notes
remove as friend: remove as friend
add as friend: add as friend
mapper since: "Mapper since:"
@ -1872,17 +1872,18 @@ en:
back: "View all blocks"
revoker: "Revoker:"
needs_view: "The user needs to log in before this block will be cleared."
bugs:
note:
rss:
description_area: "A list of bugs, reported, commented on or closed in your area [({{min_lat}}|{{min_lon}}) -- ({{max_lat}}|{{max_lon}})]"
description_item: "An rss feed for bug {{id}}"
closed: "closed bug (near {{place}})"
new: "new bug (near {{place}})"
title: "OpenStreetMap Notes"
description_area: "A list of notes, reported, commented on or closed in your area [({{min_lat}}|{{min_lon}}) -- ({{max_lat}}|{{max_lon}})]"
description_item: "An rss feed for note {{id}}"
closed: "closed note (near {{place}})"
new: "new note (near {{place}})"
comment: "new comment (near {{place}})"
user:
title_user: "Bugs submitted or commented on by {{user}}"
heading_user: "{{user}}'s bugs"
description_user: "Bugs submitted or commented on by {{user}}"
mine:
title: "Notes submitted or commented on by {{user}}"
heading: "{{user}}'s notes"
description: "Notes submitted or commented on by {{user}}"
id: "Id"
last_changed: "Last changed"

View file

@ -75,21 +75,21 @@ ActionController::Routing::Routes.draw do |map|
map.connect "api/#{API_VERSION}/amf/write", :controller =>'amf', :action =>'amf_write'
map.connect "api/#{API_VERSION}/swf/trackpoints", :controller =>'swf', :action =>'trackpoints'
# Map Bugs API
map.connect "api/#{API_VERSION}/bugs", :controller => 'map_bugs', :action => 'list'
map.connect "api/#{API_VERSION}/bugs/search", :controller => 'map_bugs', :action => 'search'
map.connect "api/#{API_VERSION}/bugs/rss", :controller =>'map_bugs', :action => 'rss'
map.connect "api/#{API_VERSION}/bug/create", :controller => 'map_bugs', :action => 'create'
map.connect "api/#{API_VERSION}/bug/:id/comment", :controller => 'map_bugs', :action => 'update', :id => /\d+/
map.connect "api/#{API_VERSION}/bug/:id/close", :controller => 'map_bugs', :action => 'close', :id => /\d+/
map.connect "api/#{API_VERSION}/bug/:id", :controller => 'map_bugs', :action => 'read', :id => /\d+/, :conditions => { :method => :get }
map.connect "api/#{API_VERSION}/bug/:id", :controller => 'map_bugs', :action => 'delete', :id => /\d+/, :conditions => { :method => :delete }
map.connect "api/#{API_VERSION}/bugs/getBugs", :controller => 'map_bugs', :action => 'list'
map.connect "api/#{API_VERSION}/bugs/addPOIexec", :controller => 'map_bugs', :action => 'create'
map.connect "api/#{API_VERSION}/bugs/closePOIexec", :controller => 'map_bugs', :action => 'close'
map.connect "api/#{API_VERSION}/bugs/editPOIexec", :controller => 'map_bugs', :action => 'update'
map.connect "api/#{API_VERSION}/bugs/getGPX", :controller => 'map_bugs', :action => 'list', :format => :gpx
map.connect "api/#{API_VERSION}/bugs/getRSSfeed", :controller => 'map_bugs', :action => 'rss'
# Map notes API
map.connect "api/#{API_VERSION}/notes", :controller => 'note', :action => 'list'
map.connect "api/#{API_VERSION}/notes/search", :controller => 'note', :action => 'search'
map.connect "api/#{API_VERSION}/notes/rss", :controller =>'notes', :action => 'rss'
map.connect "api/#{API_VERSION}/note/create", :controller => 'note', :action => 'create'
map.connect "api/#{API_VERSION}/note/:id/comment", :controller => 'note', :action => 'update', :id => /\d+/
map.connect "api/#{API_VERSION}/note/:id/close", :controller => 'note', :action => 'close', :id => /\d+/
map.connect "api/#{API_VERSION}/note/:id", :controller => 'note', :action => 'read', :id => /\d+/, :conditions => { :method => :get }
map.connect "api/#{API_VERSION}/note/:id", :controller => 'note', :action => 'delete', :id => /\d+/, :conditions => { :method => :delete }
map.connect "api/#{API_VERSION}/notes/getBugs", :controller => 'note', :action => 'list'
map.connect "api/#{API_VERSION}/notes/addPOIexec", :controller => 'note', :action => 'create'
map.connect "api/#{API_VERSION}/notes/closePOIexec", :controller => 'note', :action => 'close'
map.connect "api/#{API_VERSION}/notes/editPOIexec", :controller => 'note', :action => 'update'
map.connect "api/#{API_VERSION}/notes/getGPX", :controller => 'note', :action => 'list', :format => :gpx
map.connect "api/#{API_VERSION}/notes/getRSSfeed", :controller => 'note', :action => 'rss'
# Data browsing
map.connect '/browse/start', :controller => 'browse', :action => 'start'
@ -104,8 +104,8 @@ ActionController::Routing::Routes.draw do |map|
map.connect '/user/:display_name/edits', :controller => 'changeset', :action => 'list'
map.connect '/browse/changesets/feed', :controller => 'changeset', :action => 'list', :format => :atom
map.connect '/browse/changesets', :controller => 'changeset', :action => 'list'
map.connect '/browse/bug/:id', :controller => 'browse', :action => 'bug', :id => /\d+/
map.connect '/user/:display_name/bugs', :controller => 'map_bugs', :action => 'mine'
map.connect '/browse/note/:id', :controller => 'browse', :action => 'note', :id => /\d+/
map.connect '/user/:display_name/notes', :controller => 'note', :action => 'mine'
map.connect '/browse', :controller => 'changeset', :action => 'list'
# web site

View file

@ -4,32 +4,20 @@ class CleanupBugTables < ActiveRecord::Migration
rename_column :map_bugs, :last_changed, :updated_at
rename_column :map_bugs, :date_closed, :closed_at
rename_index :map_bugs, :map_bugs_tile_idx, :map_bugs_tile_staus_idx
rename_index :map_bugs, :map_bugs_changed_idx, :map_bugs_updated_at_idx
rename_index :map_bugs, :map_bugs_created_idx, :map_bugs_created_at_idx
rename_column :map_bug_comment, :date_created, :created_at
rename_column :map_bug_comment, :commenter_name, :author_name
rename_column :map_bug_comment, :commenter_ip, :author_ip
rename_column :map_bug_comment, :commenter_id, :author_id
rename_column :map_bug_comment, :comment, :body
rename_index :map_bug_comment, :map_bug_comment_id_idx, :map_bug_comment_bug_id_idx
end
def self.down
rename_index :map_bug_comment, :map_bug_comment_bug_id_idx, :map_bug_comment_id_idx
rename_column :map_bug_comment, :body, :comment
rename_column :map_bug_comment, :author_id, :commenter_id
rename_column :map_bug_comment, :author_ip, :commenter_ip
rename_column :map_bug_comment, :author_name, :commenter_name
rename_column :map_bug_comment, :created_at, :date_created
rename_index :map_bugs, :map_bugs_created_at_idx, :map_bugs_created_idx
rename_index :map_bugs, :map_bugs_updated_at_idx, :map_bugs_changed_idx
rename_index :map_bugs, :map_bugs_tile_staus_idx, :map_bugs_tile_idx
rename_column :map_bugs, :closed_at, :date_closed
rename_column :map_bugs, :updated_at, :last_changed
rename_column :map_bugs, :created_at, :date_created

View file

@ -0,0 +1,55 @@
require 'lib/migrate'
class RenameBugsToNotes < ActiveRecord::Migration
def self.up
rename_enumeration "map_bug_status_enum", "note_status_enum"
rename_enumeration "map_bug_event_enum", "note_event_enum"
rename_table :map_bugs, :notes
rename_sequence :notes, "map_bugs_id_seq", "notes_id_seq"
rename_index :notes, "map_bugs_pkey", "notes_pkey"
rename_index :notes, "map_bugs_changed_idx", "notes_updated_at_idx"
rename_index :notes, "map_bugs_created_idx", "notes_created_at_idx"
rename_index :notes, "map_bugs_tile_idx", "notes_tile_status_idx"
remove_foreign_key :map_bug_comment, [:bug_id], :map_bugs, [:id]
rename_column :map_bug_comment, :author_id, :commenter_id
remove_foreign_key :map_bug_comment, [:commenter_id], :users, [:id]
rename_column :map_bug_comment, :commenter_id, :author_id
rename_table :map_bug_comment, :note_comments
rename_column :note_comments, :bug_id, :note_id
rename_sequence :note_comments, "map_bug_comment_id_seq", "note_comments_id_seq"
rename_index :note_comments, "map_bug_comment_pkey", "note_comments_pkey"
rename_index :note_comments, "map_bug_comment_id_idx", "note_comments_note_id_idx"
add_foreign_key :note_comments, [:note_id], :notes, [:id]
add_foreign_key :note_comments, [:author_id], :users, [:id]
end
def self.down
remove_foreign_key :note_comments, [:author_id], :users, [:id]
remove_foreign_key :note_comments, [:note_id], :notes, [:id]
rename_index :note_comments, "note_comments_note_id_idx", "map_bug_comment_id_idx"
rename_index :notes, "note_comments_pkey", "map_bug_comment_pkey"
rename_column :note_comments, :note_id, :bug_id
rename_sequence :note_comments, "note_comments_id_seq", "map_bug_comment_id_seq"
rename_table :note_comments, :map_bug_comment
rename_column :map_bug_comment, :author_id, :commenter_id
add_foreign_key :map_bug_comment, [:commenter_id], :users, [:id]
rename_column :map_bug_comment, :commenter_id, :author_id
add_foreign_key :map_bug_comment, [:bug_id], :notes, [:id]
rename_index :notes, "notes_tile_status_idx", "map_bugs_tile_idx"
rename_index :notes, "notes_created_at_idx", "map_bugs_created_idx"
rename_index :notes, "notes_updated_at_idx", "map_bugs_changed_idx"
rename_index :notes, "notes_pkey", "map_bugs_pkey"
rename_sequence :notes, "notes_id_seq", "map_bugs_id_seq"
rename_table :notes, :map_bugs
rename_enumeration "note_event_enum", "map_bug_event_enum"
rename_enumeration "note_status_enum", "map_bug_status_enum"
end
end

View file

@ -105,11 +105,11 @@ module ActiveRecord
@enumerations ||= Hash.new
end
def create_enumeration (enumeration_name, values)
def create_enumeration(enumeration_name, values)
enumerations[enumeration_name] = values
end
def drop_enumeration (enumeration_name)
def drop_enumeration(enumeration_name)
enumerations.delete(enumeration_name)
end
@ -158,29 +158,34 @@ module ActiveRecord
return ""
end
def change_engine (table_name, engine)
def change_engine(table_name, engine)
end
def add_fulltext_index (table_name, column)
execute "CREATE INDEX #{table_name}_#{column}_idx on #{table_name} (#{column})"
def add_fulltext_index(table_name, column)
execute "CREATE INDEX #{table_name}_#{column}_idx ON #{table_name} (#{column})"
end
def enumerations
@enumerations ||= Hash.new
end
def create_enumeration (enumeration_name, values)
def create_enumeration(enumeration_name, values)
enumerations[enumeration_name] = values
execute "create type #{enumeration_name} as enum ('#{values.join '\',\''}')"
execute "CREATE TYPE #{enumeration_name} AS ENUM ('#{values.join '\',\''}')"
end
def drop_enumeration (enumeration_name)
execute "drop type #{enumeration_name}"
def drop_enumeration(enumeration_name)
execute "DROP TYPE #{enumeration_name}"
enumerations.delete(enumeration_name)
end
def rename_enumeration(old_name, new_name)
execute "ALTER TYPE #{quote_table_name(old_name)} RENAME TO #{quote_table_name(new_name)}"
end
def alter_primary_key(table_name, new_columns)
execute "alter table #{table_name} drop constraint #{table_name}_pkey; alter table #{table_name} add primary key (#{new_columns.join(',')})"
execute "ALTER TABLE #{table_name} DROP CONSTRAINT #{table_name}_pkey"
execute "ALTER TABLE #{table_name} ADD PRIMARY KEY (#{new_columns.join(',')})"
end
def interval_constant(interval)
@ -201,6 +206,14 @@ module ActiveRecord
quoted_column_names = column_names.map { |e| quote_column_name(e) }.join(", ")
execute "CREATE #{index_type} INDEX #{quote_column_name(index_name)} ON #{quote_table_name(table_name)} USING #{index_method} (#{quoted_column_names})"
end
def rename_index(table_name, old_name, new_name)
execute "ALTER INDEX #{quote_table_name(old_name)} RENAME TO #{quote_table_name(new_name)}"
end
def rename_sequence(table_name, old_name, new_name)
execute "ALTER SEQUENCE #{quote_table_name(old_name)} RENAME TO #{quote_table_name(new_name)}"
end
end
end
end

View file

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Before After
Before After

View file

@ -248,7 +248,7 @@ OpenLayers.Layer.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Layer.Markers,
if(!bounds) return false;
bounds.transform(this.map.getProjectionObject(), this.apiProjection);
this.apiRequest("bugs"
this.apiRequest("notes"
+ "?bbox="+this.round(bounds.left, 5)
+ ","+this.round(bounds.bottom, 5)
+ ","+this.round(bounds.right, 5)
@ -467,7 +467,7 @@ OpenLayers.Layer.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Layer.Markers,
* @param String description
*/
createBug: function(lonlat, description) {
this.apiRequest("bug/create"
this.apiRequest("note/create"
+ "?lat="+encodeURIComponent(lonlat.lat)
+ "&lon="+encodeURIComponent(lonlat.lon)
+ "&text="+encodeURIComponent(description)
@ -482,7 +482,7 @@ OpenLayers.Layer.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Layer.Markers,
* @param String comment
*/
submitComment: function(id, comment) {
this.apiRequest("bug/"+encodeURIComponent(id)+"/comment"
this.apiRequest("note/"+encodeURIComponent(id)+"/comment"
+ "?text="+encodeURIComponent(comment)
+ "&name="+encodeURIComponent(this.getUserName())
+ "&format=js"
@ -494,7 +494,7 @@ OpenLayers.Layer.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Layer.Markers,
* @param Number id
*/
closeBug: function(id) {
this.apiRequest("bug/"+encodeURIComponent(id)+"/close"
this.apiRequest("note/"+encodeURIComponent(id)+"/close"
+ "?format=js"
);
},