From: Tom Hughes Date: Tue, 11 May 2010 18:53:57 +0000 (+0100) Subject: Merge branch 'master' into openstreetbugs X-Git-Tag: live~6138^2~212 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/959442d087b9b25fbec9c78ec122106b82d887dd?hp=-c Merge branch 'master' into openstreetbugs --- 959442d087b9b25fbec9c78ec122106b82d887dd diff --combined config/locales/en.yml index 8afaa9717,5abae7222..93f114df4 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@@ -262,17 -262,6 +262,17 @@@ en download_xml: "Download XML" view_history: "view history" edit: "edit" + bug: + open_title: "Unresolved issue: {{bug_name}}" + closed_title: "Resolved issue: {{bug_name}}" + created_at: "Created at:" + edited_at: "Edited at:" + closed_at: "Closed at:" + opened_by: "Opened by:" + description: "Description:" + comment_by: "Comment by: " + comment: "Comment:" + date: "Date:" changeset: changeset_paging_nav: showing_page: "Showing page {{page}}" @@@ -1528,7 -1517,7 +1528,7 @@@ no_auto_account_create: "Unfortunately we are not currently able to create an account for you automatically." contact_webmaster: 'Please contact the webmaster to arrange for an account to be created - we will try and deal with the request as quickly as possible.' fill_form: "Fill in the form and we will send you a quick email to activate your account." - license_agreement: 'By creating an account, you agree that all data you submit to the Openstreetmap project is to be (non-exclusively) licensed under this Creative Commons license (by-sa).' + license_agreement: 'When you confirm your account you will need to agree to the contributor terms.' email address: "Email Address:" confirm email address: "Confirm Email Address:" not displayed publicly: 'Not displayed publicly (see privacy policy)' @@@ -1536,8 -1525,23 +1536,23 @@@ display name description: "Your publicly displayed username. You can change this later in the preferences." password: "Password:" confirm password: "Confirm Password:" - signup: Signup + continue: Continue flash create success message: "User was successfully created. Check your email for a confirmation note, and you will be mapping in no time :-)

Please note that you will not be able to login until you've received and confirmed your email address.

If you use an antispam system which sends confirmation requests then please make sure you whitelist webmaster@openstreetmap.org as we are unable to reply to any confirmation requests." + terms: + heading: "Contributor terms" + press accept button: "Please read the agreement below and press the agree button to create your account." + consider_pd: "I consider my contributions to be in the Public Domain" + consider_pd_why: "what's this?" + consider_pd_why_url: http://wiki.openstreetmap.org/wiki/Why_would_I_want_my_contributions_to_be_public_domain + agree: Agree + declined: "http://wiki.openstreetmap.org/wiki/Contributor_Terms_Declined" + decline: "Decline" + legale_select: "Please select your country of residence:" + legale_button: "Go" + legale_names: + france: "France" + italy: "Italy" + rest_of_world: "Rest of the world" no_such_user: title: "No such user" heading: "The user {{user}} does not exist" @@@ -1786,20 -1790,6 +1801,20 @@@ back: "View all blocks" revoker: "Revoker:" needs_view: "The user needs to log in before this block will be cleared." + bugs: + 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}})" + 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}}" + id: "Id" + last_changed: "Last changed" + javascripts: map: base: diff --combined config/routes.rb index 579662979,1c67eaa6e..6f574f659 --- a/config/routes.rb +++ b/config/routes.rb @@@ -70,27 -70,6 +70,27 @@@ ActionController::Routing::Routes.draw map.connect "api/#{API_VERSION}/amf/read", :controller =>'amf', :action =>'amf_read' 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/getBugs", :controller =>'map_bugs', :action =>'get_bugs' + map.connect "api/#{API_VERSION}/bugs/addPOIexec", :controller =>'map_bugs', :action =>'add_bug' + map.connect "api/#{API_VERSION}/bugs/closePOIexec", :controller =>'map_bugs', :action =>'close_bug' + map.connect "api/#{API_VERSION}/bugs/editPOIexec", :controller =>'map_bugs', :action =>'edit_bug' + map.connect "api/#{API_VERSION}/bugs/getGPX", :controller =>'map_bugs', :action =>'gpx_bugs' + map.connect "api/#{API_VERSION}/bugs/getRSSfeed", :controller =>'map_bugs', :action =>'rss' + + map.connect "api/#{API_VERSION}/bugs", :controller => 'map_bugs', :action => 'get_bugs' + 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 => 'add_bug' + map.connect "api/#{API_VERSION}/bug/:id/comment", :controller => 'map_bugs', :action => 'edit_bug', :id => /\d+/ + map.connect "api/#{API_VERSION}/bug/:id/close", :controller => 'map_bugs', :action => 'close_bug', :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 '/user/:display_name/bugs', :controller => 'map_bugs', :action => 'my_bugs' + + # Data browsing map.connect '/browse', :controller => 'changeset', :action => 'list' @@@ -104,7 -83,6 +104,7 @@@ map.changeset '/browse/changeset/:id', :controller => 'browse', :action => 'changeset', :id => /\d+/ map.connect '/browse/changesets', :controller => 'changeset', :action => 'list' map.connect '/browse/changesets/feed', :controller => 'changeset', :action => 'list', :format => :atom + map.connect '/browse/bug/:id', :controller => 'browse', :action => 'bug', :id => /\d+/ # web site map.root :controller => 'site', :action => 'index' @@@ -120,6 -98,7 +120,7 @@@ map.connect '/offline', :controller => 'site', :action => 'offline' map.connect '/key', :controller => 'site', :action => 'key' map.connect '/user/new', :controller => 'user', :action => 'new' + map.connect '/user/terms', :controller => 'user', :action => 'terms' map.connect '/user/save', :controller => 'user', :action => 'save' map.connect '/user/confirm', :controller => 'user', :action => 'confirm' map.connect '/user/confirm-email', :controller => 'user', :action => 'confirm_email' diff --combined db/migrate/053_add_map_bug_tables.rb index 2d3b7348b,000000000..2d3b7348b mode 100644,000000..100644 --- a/db/migrate/053_add_map_bug_tables.rb +++ b/db/migrate/053_add_map_bug_tables.rb @@@ -1,33 -1,0 +1,33 @@@ +require 'lib/migrate' + +class AddMapBugTables < ActiveRecord::Migration + def self.up + + create_enumeration :map_bug_status_enum, ["open", "closed","hidden"] + + create_table :map_bugs do |t| + t.column :id, :bigint, :null => false + t.integer :latitude, :null => false + t.integer :longitude, :null => false + t.column :tile, :bigint, :null => false + t.datetime :last_changed, :null => false + t.datetime :date_created, :null => false + t.string :nearby_place + t.string :text + t.column :status, :map_bug_status_enum, :null => false + + end + + add_index :map_bugs, [:tile,:status], :name => "map_bugs_tile_idx" + add_index :map_bugs, [:last_changed], :name => "map_bugs_changed_idx" + add_index :map_bugs, [:date_created], :name => "map_bugs_created_idx" + end + + def self.down + remove_index :map_bugs, :name => "map_bugs_tile_idx" + remove_index :map_bugs, :name => "map_bugs_changed_idx" + remove_index :map_bugs, :name => "map_bugs_created_idx" + drop_table :map_bugs + drop_enumeration :map_bug_status_enum + end +end diff --combined db/migrate/054_refactor_map_bug_tables.rb index b45f935cc,000000000..b45f935cc mode 100644,000000..100644 --- a/db/migrate/054_refactor_map_bug_tables.rb +++ b/db/migrate/054_refactor_map_bug_tables.rb @@@ -1,36 -1,0 +1,36 @@@ +require 'lib/migrate' + +class RefactorMapBugTables < ActiveRecord::Migration + def self.up + + + create_table :map_bug_comment do |t| + t.column :id, :bigint, :null => false + t.column :bug_id, :bigint, :null => false + t.boolean :visible, :null => false + t.datetime :date_created, :null => false + t.string :commenter_name + t.string :commenter_ip + t.column :commenter_id, :bigint + t.string :comment + end + + remove_column :map_bugs, :text + + add_index :map_bug_comment, [:bug_id], :name => "map_bug_comment_id_idx" + add_foreign_key :map_bug_comment, [:bug_id], :map_bugs, [:id] + add_foreign_key :map_bug_comment, [:commenter_id], :users, [:id] + + end + + def self.down + + add_column :map_bugs, :text, :string + + remove_index :map_bugs, :name => "map_bug_comment_id_idx" + remove_foreign_key :map_bug_comment, [:bug_id] + remove_foreign_key :map_bug_comment, [:commenter_id] + + drop_table :map_bugs_comment + end +end diff --combined db/migrate/055_change_map_bug_comment_type.rb index bf009c3dd,000000000..bf009c3dd mode 100644,000000..100644 --- a/db/migrate/055_change_map_bug_comment_type.rb +++ b/db/migrate/055_change_map_bug_comment_type.rb @@@ -1,11 -1,0 +1,11 @@@ +require 'lib/migrate' + +class ChangeMapBugCommentType < ActiveRecord::Migration + def self.up + change_column :map_bug_comment, :comment, :text + end + + def self.down + change_column :map_bug_comment, :comment, :string + end +end diff --combined db/migrate/056_add_date_closed.rb index 7f609cade,000000000..7f609cade mode 100644,000000..100644 --- a/db/migrate/056_add_date_closed.rb +++ b/db/migrate/056_add_date_closed.rb @@@ -1,13 -1,0 +1,13 @@@ +require 'lib/migrate' + +class AddDateClosed < ActiveRecord::Migration + def self.up + + add_column :map_bugs, :date_closed, :timestamp + end + + def self.down + + remove_column :map_bugs, :date_closed + end +end diff --combined db/migrate/057_add_map_bug_comment_event.rb index ff5f0b352,000000000..ff5f0b352 mode 100644,000000..100644 --- a/db/migrate/057_add_map_bug_comment_event.rb +++ b/db/migrate/057_add_map_bug_comment_event.rb @@@ -1,14 -1,0 +1,14 @@@ +require 'lib/migrate' + +class AddMapBugCommentEvent < ActiveRecord::Migration + def self.up + create_enumeration :map_bug_event_enum, ["opened", "closed","reopened","commented","hidden"] + add_column :map_bug_comment, :event, :map_bug_event_enum + end + + def self.down + + remove_column :map_bug_comment, :event + drop_enumeration :map_bug_event_enum + end +end diff --combined lib/osm.rb index 2a1ca089e,c92655aee..e2fffd17f --- a/lib/osm.rb +++ b/lib/osm.rb @@@ -447,7 -447,7 +447,7 @@@ module OS end end - def self.IPLocation(ip_address) + def self.IPToCountry(ip_address) Timeout::timeout(4) do ipinfo = Quova::IpInfo.new(ip_address) @@@ -459,14 -459,24 +459,24 @@@ country = "GB" if country == "UK" end end + + return country.upcase + end - country = Country.find_by_code(country.upcase) + return nil + rescue Exception + return nil + end + + def self.IPLocation(ip_address) + code = OSM.IPToCountry(ip_address) + + unless code.nil? + country = Country.find_by_code(code) return { :minlon => country.min_lon, :minlat => country.min_lat, :maxlon => country.max_lon, :maxlat => country.max_lat } end - return nil - rescue Exception return nil end @@@ -490,7 -500,7 +500,7 @@@ # Return an SQL fragment to select a given area of the globe def self.sql_for_area(minlat, minlon, maxlat, maxlon, prefix = nil) - tilesql = QuadTile.sql_for_area(minlat, minlon, maxlat, maxlon, prefix) + tilesql = QuadTile.sql_for_area(minlat, minlon, maxlat, maxlon, prefix) minlat = (minlat * 10000000).round minlon = (minlon * 10000000).round maxlat = (maxlat * 10000000).round @@@ -499,16 -509,6 +509,16 @@@ return "#{tilesql} AND #{prefix}latitude BETWEEN #{minlat} AND #{maxlat} AND #{prefix}longitude BETWEEN #{minlon} AND #{maxlon}" end + # Return an SQL fragment to select a given area of the globe without using the quadtile index + def self.sql_for_area_no_quadtile(minlat, minlon, maxlat, maxlon, prefix = nil, without_quadtile = :false) + minlat = (minlat * 10000000).round + minlon = (minlon * 10000000).round + maxlat = (maxlat * 10000000).round + maxlon = (maxlon * 10000000).round + + return "#{prefix}latitude BETWEEN #{minlat} AND #{maxlat} AND #{prefix}longitude BETWEEN #{minlon} AND #{maxlon}" + end + # Return a spam score for a chunk of text def self.spam_score(text) link_count = 0 @@@ -529,4 -529,10 +539,10 @@@ return [link_proportion - 0.2, 0.0].max * 200 + link_count * 20 end + + def self.legal_text_for_country(country_code) + file_name = File.join(RAILS_ROOT, "config", "legales", country_code.to_s + ".yml") + file_name = File.join(RAILS_ROOT, "config", "legales", APP_CONFIG['default_legale'] + ".yml") unless File.exist? file_name + YAML::load_file(file_name) + end end