]> git.openstreetmap.org Git - rails.git/commitdiff
Merge branch 'master' into openstreetbugs
authorTom Hughes <tom@compton.nu>
Tue, 11 May 2010 18:53:57 +0000 (19:53 +0100)
committerTom Hughes <tom@compton.nu>
Tue, 11 May 2010 18:53:57 +0000 (19:53 +0100)
1  2 
config/locales/en.yml
config/routes.rb
db/migrate/053_add_map_bug_tables.rb
db/migrate/054_refactor_map_bug_tables.rb
db/migrate/055_change_map_bug_comment_type.rb
db/migrate/056_add_date_closed.rb
db/migrate/057_add_map_bug_comment_event.rb
lib/osm.rb

diff --combined config/locales/en.yml
index 8afaa971742e5ec07e3090067205b6e964649850,5abae7222ec5b3617d17e3ab10790e243ffa3af3..93f114df429d44471213139ce406dad9fb1fbeac
@@@ -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}}"
        no_auto_account_create: "Unfortunately we are not currently able to create an account for you automatically."
        contact_webmaster: 'Please contact the <a href="mailto:webmaster@openstreetmap.org">webmaster</a> 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 <a href="http://creativecommons.org/licenses/by-sa/2.0/">this Creative Commons license (by-sa)</a>.'
+       license_agreement: 'When you confirm your account you will need to agree to the <a href="http://www.osmfoundation.org/wiki/License/Contributor_Terms">contributor terms</a>.'
        email address: "Email Address:"
        confirm email address: "Confirm Email Address:"
        not displayed publicly: 'Not displayed publicly (see <a href="http://wiki.openstreetmap.org/wiki/Privacy_Policy" title="wiki privacy policy including section on email addresses">privacy policy</a>)'
        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 :-)<br /><br />Please note that you will not be able to login until you've received and confirmed your email address.<br /><br />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"
        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 579662979c9d083cb77c4530b4fa7cbc91280008,1c67eaa6eb7dde8a115b84920a0b5d45b4348ee1..6f574f6595ff3926ed00db626c3d840ccf1996da
@@@ -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'
    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'
    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'
index 2d3b7348bd3d62bc953a51f1dc0ba935b667f488,0000000000000000000000000000000000000000..2d3b7348bd3d62bc953a51f1dc0ba935b667f488
mode 100644,000000..100644
--- /dev/null
@@@ -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
index b45f935cc32c7db4daa847579ec0894a4bc0ab42,0000000000000000000000000000000000000000..b45f935cc32c7db4daa847579ec0894a4bc0ab42
mode 100644,000000..100644
--- /dev/null
@@@ -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
index bf009c3dd2721443d9cf4719bfe70558b2eae08a,0000000000000000000000000000000000000000..bf009c3dd2721443d9cf4719bfe70558b2eae08a
mode 100644,000000..100644
--- /dev/null
@@@ -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
index 7f609cade402653801823e4ebf4d67351c653ac3,0000000000000000000000000000000000000000..7f609cade402653801823e4ebf4d67351c653ac3
mode 100644,000000..100644
--- /dev/null
@@@ -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
index ff5f0b352e27b44ec4bc60ea78fa88dc29c2ab6d,0000000000000000000000000000000000000000..ff5f0b352e27b44ec4bc60ea78fa88dc29c2ab6d
mode 100644,000000..100644
--- /dev/null
@@@ -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 2a1ca089eb70ca681af2b7b3c2e1259d72e3de11,c92655aeea207b48393645e6bb9aeb4bcf478c4c..e2fffd17fe59492c08e6c2b4ea7b8a776738eb9e
@@@ -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)
  
            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
  
  
    # 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
      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
  
      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