From: Anton Khorev Date: Wed, 18 Sep 2024 12:28:13 +0000 (+0300) Subject: Merge branch 'pull/5209' X-Git-Tag: live~660 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/f90c7c497088dc63f03920b3ef7727a484e00b62?hp=b969c6f7ab842e933f08e89d296478c25dffb349 Merge branch 'pull/5209' --- diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index dc1092360..7384a8d95 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -26,6 +26,7 @@ FactoryBot/ExcessiveCreateList: - 'test/controllers/notes_controller_test.rb' - 'test/controllers/traces_controller_test.rb' - 'test/controllers/user_blocks_controller_test.rb' + - 'test/system/users_test.rb' # Offense count: 635 # This cop supports safe autocorrection (--autocorrect). diff --git a/Gemfile.lock b/Gemfile.lock index f496e5a98..1012a09db 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -95,17 +95,17 @@ GEM autoprefixer-rails (10.4.19.0) execjs (~> 2) aws-eventstream (1.3.0) - aws-partitions (1.972.0) - aws-sdk-core (3.203.0) + aws-partitions (1.976.0) + aws-sdk-core (3.205.0) aws-eventstream (~> 1, >= 1.3.0) aws-partitions (~> 1, >= 1.651.0) aws-sigv4 (~> 1.9) jmespath (~> 1, >= 1.6.1) - aws-sdk-kms (1.89.0) - aws-sdk-core (~> 3, >= 3.203.0) + aws-sdk-kms (1.91.0) + aws-sdk-core (~> 3, >= 3.205.0) aws-sigv4 (~> 1.5) - aws-sdk-s3 (1.160.0) - aws-sdk-core (~> 3, >= 3.203.0) + aws-sdk-s3 (1.162.0) + aws-sdk-core (~> 3, >= 3.205.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.5) aws-sigv4 (1.9.1) @@ -265,7 +265,7 @@ GEM reline htmlentities (4.3.4) http_accept_language (2.1.1) - i18n (1.14.5) + i18n (1.14.6) concurrent-ruby (~> 1.0) i18n-js (3.9.2) i18n (>= 0.6.6) @@ -299,7 +299,7 @@ GEM irb (1.14.0) rdoc (>= 4.0.0) reline (>= 0.4.2) - jbuilder (2.12.0) + jbuilder (2.13.0) actionview (>= 5.0.0) activesupport (>= 5.0.0) jmespath (1.6.2) @@ -308,7 +308,7 @@ GEM railties (>= 4.2.0) thor (>= 0.14, < 2.0) json (2.7.2) - jwt (2.8.2) + jwt (2.9.0) base64 kgio (2.11.4) kramdown (2.4.0) @@ -384,8 +384,8 @@ GEM omniauth-github (2.0.1) omniauth (~> 2.0) omniauth-oauth2 (~> 1.8) - omniauth-google-oauth2 (1.1.3) - jwt (>= 2.0) + omniauth-google-oauth2 (1.2.0) + jwt (>= 2.9) oauth2 (~> 2.0) omniauth (~> 2.0) omniauth-oauth2 (~> 1.8) @@ -499,7 +499,7 @@ GEM rexml (3.3.7) rinku (2.0.6) rotp (6.3.0) - rouge (4.3.0) + rouge (4.4.0) rtlcss (0.2.1) mini_racer (>= 0.6.3) rubocop (1.66.1) @@ -521,7 +521,7 @@ GEM rubocop-minitest (0.36.0) rubocop (>= 1.61, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) - rubocop-performance (1.21.1) + rubocop-performance (1.22.1) rubocop (>= 1.48.1, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) rubocop-rails (2.26.1) @@ -581,13 +581,13 @@ GEM thor (1.3.2) tilt (2.4.0) timeout (0.4.1) - turbo-rails (2.0.6) + turbo-rails (2.0.7) actionpack (>= 6.0.0) activejob (>= 6.0.0) railties (>= 6.0.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - unicode-display_width (2.5.0) + unicode-display_width (2.6.0) uri (0.13.1) validates_email_format_of (1.8.2) i18n (>= 0.8.0) diff --git a/app/assets/images/key/opnvkarte/bus_stop13.svg b/app/assets/images/key/opnvkarte/bus_stop13.svg deleted file mode 100644 index ae4ffeeaf..000000000 --- a/app/assets/images/key/opnvkarte/bus_stop13.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/app/assets/images/key/opnvkarte/bus_stop15.svg b/app/assets/images/key/opnvkarte/bus_stop15.svg deleted file mode 100644 index a25991954..000000000 --- a/app/assets/images/key/opnvkarte/bus_stop15.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/app/assets/images/key/opnvkarte/rail17.svg b/app/assets/images/key/opnvkarte/rail17.svg deleted file mode 100644 index 8cada29c9..000000000 --- a/app/assets/images/key/opnvkarte/rail17.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/app/assets/images/key/opnvkarte/stop13.svg b/app/assets/images/key/opnvkarte/stop13.svg deleted file mode 100644 index cfe65b344..000000000 --- a/app/assets/images/key/opnvkarte/stop13.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/app/assets/images/key/opnvkarte/stop15.svg b/app/assets/images/key/opnvkarte/stop15.svg deleted file mode 100644 index 3ae62672e..000000000 --- a/app/assets/images/key/opnvkarte/stop15.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/app/assets/javascripts/embed.js.erb b/app/assets/javascripts/embed.js.erb index 9a0ec07d3..66cd02b98 100644 --- a/app/assets/javascripts/embed.js.erb +++ b/app/assets/javascripts/embed.js.erb @@ -37,18 +37,16 @@ window.onload = function () { map.attributionControl.setPrefix(''); map.removeControl(map.attributionControl); - if (!args.layer || args.layer === "mapnik" || args.layer === "osmarender" || args.layer === "mapquest") { - new L.OSM.Mapnik(mapnikOptions).addTo(map); - } else if (args.layer === "cyclosm") { + if (args.layer === "cyclosm") { new L.OSM.CyclOSM().addTo(map); } else if (args.layer === "cyclemap" || args.layer === "cycle map") { new L.OSM.CycleMap(thunderforestOptions).addTo(map); } else if (args.layer === "transportmap") { new L.OSM.TransportMap(thunderforestOptions).addTo(map); - } else if (args.layer === "opnvkarte") { - new L.OSM.OPNVKarte().addTo(map); } else if (args.layer === "hot") { new L.OSM.HOT().addTo(map); + } else { + new L.OSM.Mapnik(mapnikOptions).addTo(map); } if (args.marker) { diff --git a/app/assets/javascripts/user.js b/app/assets/javascripts/user.js index 495470f2f..681ec3ace 100644 --- a/app/assets/javascripts/user.js +++ b/app/assets/javascripts/user.js @@ -1,5 +1,11 @@ //= require leaflet.locatecontrol/src/L.Control.Locate +(function () { + $(document).on("change", "#user_all", function () { + $("#user_list input[type=checkbox]").prop("checked", $("#user_all").prop("checked")); + }); +}()); + $(document).ready(function () { var defaultHomeZoom = 12; var map, marker, deleted_lat, deleted_lon; @@ -200,10 +206,6 @@ $(document).ready(function () { enableAuth(); } - $("#user_all").change(function () { - $("#user_list input[type=checkbox]").prop("checked", $("#user_all").prop("checked")); - }); - $("#content.user_confirm").each(function () { $(this).hide(); $(this).find("#confirm").submit(); diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 4b36607bb..fdc2ac4e8 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -216,20 +216,25 @@ class ApplicationController < ActionController::Base ## # wrap a web page in a timeout def web_timeout(&block) + raise Timeout::Error if Settings.web_timeout.negative? + Timeout.timeout(Settings.web_timeout, &block) rescue ActionView::Template::Error => e e = e.cause if e.is_a?(Timeout::Error) || (e.is_a?(ActiveRecord::StatementInvalid) && e.message.include?("execution expired")) - ActiveRecord::Base.connection.raw_connection.cancel - render :action => "timeout" + respond_to_timeout else raise end rescue Timeout::Error + respond_to_timeout + end + + def respond_to_timeout ActiveRecord::Base.connection.raw_connection.cancel - render :action => "timeout" + render :action => "timeout", :status => :gateway_timeout end ## diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index fc893c9c3..63a83ad1d 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -36,7 +36,7 @@ class UsersController < ApplicationController users = User.all users = users.where(:status => @params[:status]) if @params[:status] - users = users.where(:creation_ip => @params[:ip]) if @params[:ip] + users = users.where(:creation_address => @params[:ip]) if @params[:ip] @users_count = users.limit(501).count @users_count = I18n.t("count.at_least_pattern", :count => 500) if @users_count > 500 @@ -268,7 +268,6 @@ class UsersController < ApplicationController def save_new_user(email_hmac, referer = nil) current_user.data_public = true current_user.description = "" if current_user.description.nil? - current_user.creation_ip = request.remote_ip current_user.creation_address = request.remote_ip current_user.languages = http_accept_language.user_preferred_languages current_user.terms_agreed = Time.now.utc diff --git a/app/helpers/browse_helper.rb b/app/helpers/browse_helper.rb index 0ea10e219..9ea384811 100644 --- a/app/helpers/browse_helper.rb +++ b/app/helpers/browse_helper.rb @@ -86,13 +86,13 @@ module BrowseHelper max_width_for_default_padding = 35 width = 0 - pagination_items(pages, {}).each do |body| + pagination_items(pages, {}).each do |(body)| width += 2 # padding width width += body.length end link_classes = ["page-link", { "px-1" => width > max_width_for_default_padding }] - tag.ul :class => "pagination pagination-sm mb-1 ms-auto" do + tag.ul :class => "pagination pagination-sm mb-2" do pagination_items(pages, {}).each do |body, page_or_class| linked = !(page_or_class.is_a? String) link = if linked diff --git a/app/models/user.rb b/app/models/user.rb index 441805f39..6b5418256 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -15,7 +15,6 @@ # pass_salt :string # email_valid :boolean default(FALSE), not null # new_email :string -# creation_ip :string # languages :string # status :enum default("pending"), not null # terms_agreed :datetime @@ -50,6 +49,8 @@ class User < ApplicationRecord require "digest" include AASM + self.ignored_columns += ["creation_ip"] + has_many :traces, -> { where(:visible => true) } has_many :diary_entries, -> { order(:created_at => :desc) }, :inverse_of => :user has_many :diary_comments, -> { order(:created_at => :desc) }, :inverse_of => :user diff --git a/app/views/changeset_comments/feeds/timeout.atom.builder b/app/views/changeset_comments/feeds/timeout.atom.builder deleted file mode 100644 index b5eeeed4a..000000000 --- a/app/views/changeset_comments/feeds/timeout.atom.builder +++ /dev/null @@ -1,12 +0,0 @@ -atom_feed(:language => I18n.locale, :schema_date => 2009, - :id => url_for(params.merge(:only_path => false)), - :root_url => url_for(params.merge(:only_path => false, :format => nil)), - "xmlns:georss" => "http://www.georss.org/georss") do |feed| - feed.title @title - - feed.subtitle :type => "xhtml" do |xhtml| - xhtml.p do |p| - p << t(".sorry") - end - end -end diff --git a/app/views/changeset_comments/feeds/timeout.html.erb b/app/views/changeset_comments/feeds/timeout.html.erb deleted file mode 100644 index 641b1dfb8..000000000 --- a/app/views/changeset_comments/feeds/timeout.html.erb +++ /dev/null @@ -1 +0,0 @@ -

<%= t ".sorry" %>

diff --git a/app/views/changeset_comments/feeds/timeout.rss.builder b/app/views/changeset_comments/feeds/timeout.rss.builder new file mode 100644 index 000000000..c56ebb879 --- /dev/null +++ b/app/views/changeset_comments/feeds/timeout.rss.builder @@ -0,0 +1,12 @@ +xml.rss("version" => "2.0", + "xmlns:dc" => "http://purl.org/dc/elements/1.1/") do + xml.channel do + if params[:changeset_id] + xml.title t("changeset_comments.feeds.show.title_particular", :changeset_id => params[:changeset_id]) + else + xml.title t("changeset_comments.feeds.show.title_all") + end + xml.link root_url + xml.description t(".sorry") + end +end diff --git a/app/views/changesets/_paging_nav.html.erb b/app/views/changesets/_paging_nav.html.erb index fbdf1d507..058738222 100644 --- a/app/views/changesets/_paging_nav.html.erb +++ b/app/views/changesets/_paging_nav.html.erb @@ -1,11 +1,9 @@ -
-

<%= type_and_paginated_count(type, pages) %>

- <% if pages.page_count > 1 %> - <%= sidebar_classic_pagination(pages, "#{type}_page") do |page| - { - :title => type_and_paginated_count(type, pages, page), - :data => { :turbo => "true" } - } - end %> - <% end %> -
+

<%= type_and_paginated_count(type, pages) %>

+<% if pages.page_count > 1 %> + <%= sidebar_classic_pagination(pages, "#{type}_page") do |page| + { + :title => type_and_paginated_count(type, pages, page), + :data => { :turbo => "true" } + } + end %> +<% end %> diff --git a/app/views/nodes/timeout.html.erb b/app/views/nodes/timeout.html.erb new file mode 100644 index 000000000..61415c650 --- /dev/null +++ b/app/views/nodes/timeout.html.erb @@ -0,0 +1,5 @@ +<% set_title(t("browse.timeout.title")) %> + +<%= render "sidebar_header", :title => t("browse.timeout.title") %> + +

<%= t ".sorry", :id => params[:id] %>

diff --git a/app/views/old_nodes/timeout.html.erb b/app/views/old_nodes/timeout.html.erb new file mode 100644 index 000000000..61415c650 --- /dev/null +++ b/app/views/old_nodes/timeout.html.erb @@ -0,0 +1,5 @@ +<% set_title(t("browse.timeout.title")) %> + +<%= render "sidebar_header", :title => t("browse.timeout.title") %> + +

<%= t ".sorry", :id => params[:id] %>

diff --git a/app/views/old_relations/timeout.html.erb b/app/views/old_relations/timeout.html.erb new file mode 100644 index 000000000..61415c650 --- /dev/null +++ b/app/views/old_relations/timeout.html.erb @@ -0,0 +1,5 @@ +<% set_title(t("browse.timeout.title")) %> + +<%= render "sidebar_header", :title => t("browse.timeout.title") %> + +

<%= t ".sorry", :id => params[:id] %>

diff --git a/app/views/old_ways/timeout.html.erb b/app/views/old_ways/timeout.html.erb new file mode 100644 index 000000000..61415c650 --- /dev/null +++ b/app/views/old_ways/timeout.html.erb @@ -0,0 +1,5 @@ +<% set_title(t("browse.timeout.title")) %> + +<%= render "sidebar_header", :title => t("browse.timeout.title") %> + +

<%= t ".sorry", :id => params[:id] %>

diff --git a/app/views/relations/timeout.html.erb b/app/views/relations/timeout.html.erb new file mode 100644 index 000000000..61415c650 --- /dev/null +++ b/app/views/relations/timeout.html.erb @@ -0,0 +1,5 @@ +<% set_title(t("browse.timeout.title")) %> + +<%= render "sidebar_header", :title => t("browse.timeout.title") %> + +

<%= t ".sorry", :id => params[:id] %>

diff --git a/app/views/user_mailer/friendship_notification.html.erb b/app/views/user_mailer/friendship_notification.html.erb index ee2dea2eb..40af762d7 100644 --- a/app/views/user_mailer/friendship_notification.html.erb +++ b/app/views/user_mailer/friendship_notification.html.erb @@ -1,3 +1,5 @@ +

<%= t ".hi", :to_user => @friendship.befriendee.display_name %>

+

<%= t ".had_added_you", :user => @friendship.befriender.display_name %>

<%= message_body do %> diff --git a/app/views/user_mailer/friendship_notification.text.erb b/app/views/user_mailer/friendship_notification.text.erb index 22c2bbfe7..104b0f1c9 100644 --- a/app/views/user_mailer/friendship_notification.text.erb +++ b/app/views/user_mailer/friendship_notification.text.erb @@ -1,3 +1,5 @@ +<%= t ".hi", :to_user => @friendship.befriendee.display_name %> + <%= t '.had_added_you', :user => @friendship.befriender.display_name %> <%= t '.see_their_profile', :userurl => @viewurl %> diff --git a/app/views/users/_user.html.erb b/app/views/users/_user.html.erb index ef50ccaf2..2fb14b6bd 100644 --- a/app/views/users/_user.html.erb +++ b/app/views/users/_user.html.erb @@ -4,10 +4,10 @@

- <% if user.creation_ip %> + <% if user.creation_address %> <%= t "users.index.summary_html", :name => link_to(user.display_name, user), - :ip_address => link_to(user.creation_ip, :ip => user.creation_ip), + :ip_address => link_to(user.creation_address, :ip => user.creation_address), :date => l(user.created_at, :format => :friendly) %> <% else %> <%= t "users.index.summary_no_ip_html", diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index c73581b25..d479b1d56 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -81,15 +81,15 @@ <%= link_to t(".comments"), diary_comments_path(@user) %> <%= number_with_delimiter(@user.diary_comments.size) %> -

  • - <% if current_user and current_user.friends_with?(@user) %> - <%= link_to t(".remove as friend"), remove_friend_path(:display_name => @user.display_name), :method => :post %> - <% elsif current_user %> - <%= link_to t(".add as friend"), make_friend_path(:display_name => @user.display_name), :method => :post %> - <% else %> - <%= link_to t(".add as friend"), make_friend_path(:display_name => @user.display_name) %> - <% end %> -
  • + <% if current_user %> +
  • + <% if current_user.friends_with?(@user) %> + <%= link_to t(".remove as friend"), remove_friend_path(:display_name => @user.display_name), :method => :post %> + <% else %> + <%= link_to t(".add as friend"), make_friend_path(:display_name => @user.display_name), :method => :post %> + <% end %> +
  • + <% end %> <% if @user.blocks.exists? %>
  • @@ -217,9 +217,9 @@
    <%= t ".email address" %>
    <%= @user.email %>
    - <% unless @user.creation_ip.nil? -%> + <% unless @user.creation_address.nil? -%>
    <%= t ".created from" %>
    -
    <%= link_to @user.creation_ip, users_path(:ip => @user.creation_ip) %>
    +
    <%= link_to @user.creation_address, users_path(:ip => @user.creation_address) %>
    <% end -%>
    <%= t ".status" %>
    <%= link_to @user.status.capitalize, users_path(:status => @user.status) %>
    diff --git a/app/views/ways/timeout.html.erb b/app/views/ways/timeout.html.erb new file mode 100644 index 000000000..61415c650 --- /dev/null +++ b/app/views/ways/timeout.html.erb @@ -0,0 +1,5 @@ +<% set_title(t("browse.timeout.title")) %> + +<%= render "sidebar_header", :title => t("browse.timeout.title") %> + +

    <%= t ".sorry", :id => params[:id] %>

    diff --git a/config/i18n-tasks.yml b/config/i18n-tasks.yml index 225078a51..2ed3b2e91 100644 --- a/config/i18n-tasks.yml +++ b/config/i18n-tasks.yml @@ -123,6 +123,7 @@ ignore_unused: - 'geocoder.search_osm_nominatim.prefix.*' - 'javascripts.*' - 'doorkeeper.*' + - 'users.auth_failure.*' # OmniAuth provider callback error messages - 'activerecord.attributes.*' - 'activerecord.models.*' - 'activerecord.help.*' diff --git a/config/key.yml b/config/key.yml index 032a24704..798d9ca54 100644 --- a/config/key.yml +++ b/config/key.yml @@ -158,57 +158,3 @@ cyclemap: - { min_zoom: 15, name: bicycle_parking, image: bicycle_parking.png } - { min_zoom: 16, name: bicycle_parking_small, image: bicycle_parking_small.svg } - { min_zoom: 16, name: toilets, image: toilets.png } -opnvkarte: - - { min_zoom: 6, name: rail, width: 52, height: 1, fill: "#868686" } - - { min_zoom: 8, name: rail, width: 52, height: 2, fill: "#868686" } - - { min_zoom: 11, name: rail, width: 52, height: 3, fill: "#868686", line: "#eeeeee", line-dasharray: 10, line-dashoffset: 9 } - - { min_zoom: 15, name: rail, width: 52, height: 4, fill: "#868686", line: "#eeeeee", line-dasharray: 10, line-dashoffset: 9, line-width: 2 } - - { min_zoom: 17, name: rail, image: rail17.svg } - - { min_zoom: 6, name: train, width: 52, height: 2, fill: "#ffc366" } - - { min_zoom: 10, name: train, width: 52, height: 3, fill: "#ffc366" } - - { min_zoom: 12, name: train, width: 52, height: 4, fill: "#ffc366" } - - { min_zoom: 14, name: train, width: 52, height: 8, fill: "#ffc366" } - - { min_zoom: 16, name: train, width: 52, height: 10, fill: "#ffc366" } - - { min_zoom: 10, name: light_rail, width: 52, height: 3, fill: "#66ff66" } - - { min_zoom: 12, name: light_rail, width: 52, height: 4, fill: "#66ff66" } - - { min_zoom: 14, name: light_rail, width: 52, height: 8, fill: "#66ff66" } - - { min_zoom: 16, name: light_rail, width: 52, height: 10, fill: "#66ff66" } - - { min_zoom: 10, name: tram, width: 52, height: 3, fill: "#3333fe" } - - { min_zoom: 12, name: tram, width: 52, height: 4, fill: "#3333fe" } - - { min_zoom: 14, name: tram, width: 52, height: 8, fill: "#3333fe" } - - { min_zoom: 16, name: tram, width: 52, height: 10, fill: "#3333fe" } - - { min_zoom: 10, name: subway, width: 52, height: 3, fill: "#33339f" } - - { min_zoom: 12, name: subway, width: 52, height: 4, fill: "#33339f" } - - { min_zoom: 14, name: subway, width: 52, height: 8, fill: "#33339f" } - - { min_zoom: 16, name: subway, width: 52, height: 10, fill: "#33339f" } - - { min_zoom: 9, name: ferry, width: 52, height: 2, fill: "#9f339f" } - - { min_zoom: 14, name: ferry, width: 52, height: 3, fill: "#9f339f" } - - { min_zoom: 10, name: trolleybus, width: 52, height: 3, fill: "#9f3333" } - - { min_zoom: 12, name: trolleybus, width: 52, height: 4, fill: "#9f3333" } - - { min_zoom: 14, name: trolleybus, width: 52, height: 8, fill: "#9f3333" } - - { min_zoom: 16, name: trolleybus, width: 52, height: 10, fill: "#9f3333" } - - { min_zoom: 11, name: bus, width: 52, height: 1, fill: "#fe3333" } - - { min_zoom: 12, name: bus, width: 52, height: 2, fill: "#fe3333" } - - { min_zoom: 13, name: bus, width: 52, height: 3, fill: "#fe3333" } - - { min_zoom: 14, name: bus, width: 52, height: 4, fill: "#fe3333" } - - { min_zoom: 16, name: bus, width: 52, height: 10, fill: "#fe3333" } - - { min_zoom: 13, name: bus_stop, image: bus_stop13.svg } - - { min_zoom: 15, name: bus_stop, image: bus_stop15.svg } - - { min_zoom: 13, name: stop, image: stop13.svg } - - { min_zoom: 15, name: stop, image: stop15.svg } - - { min_zoom: 8, name: motorway, width: 52, height: 4, fill: "#dddddd", casing: "#6d6d6d" } - - { min_zoom: 13, name: motorway, width: 52, height: 8, fill: "#dddddd", casing: "#6d6d6d" } - - { min_zoom: 15, name: motorway, width: 52, height: 13, fill: "#dddddd", casing: "#6d6d6d", line: "#ffffff", line-dasharray: 12, line-dashoffset: 4 } - - { min_zoom: 17, name: motorway, width: 52, height: 17, fill: "#dddddd", casing: "#6d6d6d", line: "#ffffff", line-dasharray: 12, line-dashoffset: 4, casing-width: 2 } - - { min_zoom: 8, name: main_road, width: 52, height: 1, fill: "#5c6d6d88" } - - { min_zoom: 11, name: main_road, width: 52, height: 4, fill: "#dddddd", casing: "#a1968b" } - - { min_zoom: 13, name: main_road, width: 52, height: 8, fill: "#dddddd", casing: "#a1968b" } - - { min_zoom: 15, name: main_road, width: 52, height: 13, fill: "#dddddd", casing: "#a1968b" } - - { min_zoom: 17, name: main_road, width: 52, height: 17, fill: "#dddddd", casing: "#a1968b" } - # landcover - - { min_zoom: 0, name: [lake, reservoir], width: 26, height: 10, fill: "#a1cbea" } - - { min_zoom: 8, name: [lake, reservoir], width: 26, height: 10, fill: "#bfd3ef" } - - { min_zoom: 4, name: [forest, wood], width: 26, height: 10, fill: "#b9c5a3" } - - { min_zoom: 4, name: built_up, width: 26, height: 10, fill: "#d8d8d8" } - - { min_zoom: 9, name: farmland, width: 26, height: 10, fill: "#eae8d6" } - - { min_zoom: 12, name: [park, allotments], width: 26, height: 10, fill: "#c2d89a" } diff --git a/config/locales/en.yml b/config/locales/en.yml index feacfcf12..fc2ab125e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -369,7 +369,7 @@ en: note: note timeout: title: Timeout Error - sorry: "Sorry, the data for the %{type} with the id %{id}, took too long to retrieve." + sorry: "Sorry, the data for the %{type} with the id %{id} took too long to retrieve." type: node: node way: way @@ -403,15 +403,30 @@ en: introduction: "Click on the map to find nearby features." nearby: "Nearby features" enclosing: "Enclosing features" + nodes: + timeout: + sorry: "Sorry, the data for the node with the id %{id} took too long to retrieve." old_nodes: not_found: sorry: "Sorry, node #%{id} version %{version} could not be found." + timeout: + sorry: "Sorry, the history of the node with the id %{id} took too long to retrieve." + ways: + timeout: + sorry: "Sorry, the data for the way with the id %{id} took too long to retrieve." old_ways: not_found: sorry: "Sorry, way #%{id} version %{version} could not be found." + timeout: + sorry: "Sorry, the history of the way with the id %{id} took too long to retrieve." + relations: + timeout: + sorry: "Sorry, the data for the relation with the id %{id} took too long to retrieve." old_relations: not_found: sorry: "Sorry, relation #%{id} version %{version} could not be found." + timeout: + sorry: "Sorry, the history of the relation with the id %{id} took too long to retrieve." changeset_comments: feeds: comment: @@ -1434,10 +1449,6 @@ en: level9: "Village Boundary" level10: "Suburb Boundary" level11: "Neighbourhood Boundary" - types: - cities: Cities - towns: Towns - places: Places results: no_results: "No results found" more_results: "More results" @@ -1672,7 +1683,6 @@ en: changeset_comment_notification: description: "OpenStreetMap Changeset #%{id}" hi: "Hi %{to_user}," - greeting: "Hi," commented: subject_own: "[OpenStreetMap] %{commenter} has commented on one of your changesets" subject_other: "[OpenStreetMap] %{commenter} has commented on a changeset you are interested in" @@ -2384,7 +2394,6 @@ en: destination: "Destination access" construction: "Roads under construction" bus_stop: "Bus stop" - stop: "Stop" bicycle_shop: "Bicycle shop" bicycle_rental: "Bicycle rental" bicycle_parking: "Bicycle parking" @@ -2685,7 +2694,6 @@ en: contributor_terms_url: "https://wiki.osmfoundation.org/wiki/Licence/Contributor_Terms" contributor_terms: "contributor terms" tou: "terms of use" - external auth: "Third Party Authentication:" continue: Sign Up terms accepted: "Thanks for accepting the new contributor terms!" email_help: diff --git a/db/migrate/20240912181413_backfill_user_creation_address.rb b/db/migrate/20240912181413_backfill_user_creation_address.rb new file mode 100644 index 000000000..3cc14f238 --- /dev/null +++ b/db/migrate/20240912181413_backfill_user_creation_address.rb @@ -0,0 +1,14 @@ +class BackfillUserCreationAddress < ActiveRecord::Migration[7.1] + class User < ApplicationRecord + end + + def up + User + .where(:creation_address => nil) + .where.not(:creation_ip => nil) + .in_batches(:of => 1000) + .update_all("creation_address = creation_ip::inet") + end + + def down; end +end diff --git a/db/migrate/20240913171951_drop_user_creation_ip.rb b/db/migrate/20240913171951_drop_user_creation_ip.rb new file mode 100644 index 000000000..7915f6ec7 --- /dev/null +++ b/db/migrate/20240913171951_drop_user_creation_ip.rb @@ -0,0 +1,5 @@ +class DropUserCreationIp < ActiveRecord::Migration[7.1] + def change + safety_assured { remove_column :users, :creation_ip, :string } + end +end diff --git a/db/structure.sql b/db/structure.sql index 9318185c6..25b2f173f 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -1482,7 +1482,6 @@ CREATE TABLE public.users ( pass_salt character varying, email_valid boolean DEFAULT false NOT NULL, new_email character varying, - creation_ip character varying, languages character varying, status public.user_status_enum DEFAULT 'pending'::public.user_status_enum NOT NULL, terms_agreed timestamp without time zone, @@ -3357,6 +3356,8 @@ INSERT INTO "schema_migrations" (version) VALUES ('23'), ('22'), ('21'), +('20240913171951'), +('20240912181413'), ('20240910175616'), ('20240822121603'), ('20240813070506'), diff --git a/script/update-spam-blocks b/script/update-spam-blocks index b5656f6ac..7d6654545 100755 --- a/script/update-spam-blocks +++ b/script/update-spam-blocks @@ -8,7 +8,7 @@ addresses = User.count( :status => %w[suspended deleted], :creation_time => Time.now.utc - 28.days..Time.now.utc }, - :group => :creation_ip + :group => :creation_address ) addresses.each do |address, count| diff --git a/test/controllers/changeset_comments/feeds_controller_test.rb b/test/controllers/changeset_comments/feeds_controller_test.rb index 20db62cef..4858eb085 100644 --- a/test/controllers/changeset_comments/feeds_controller_test.rb +++ b/test/controllers/changeset_comments/feeds_controller_test.rb @@ -68,5 +68,25 @@ module ChangesetComments get changesets_comments_feed_path(:format => "rss", :limit => 100001) assert_response :bad_request end + + def test_feed_timeout + with_settings(:web_timeout => -1) do + get changesets_comments_feed_path + end + assert_response :error + assert_equal "application/rss+xml; charset=utf-8", @response.header["Content-Type"] + assert_dom "rss>channel>title", :text => "OpenStreetMap changeset discussion" + assert_dom "rss>channel>description", :text => /the list of changeset comments you requested took too long to retrieve/ + end + + def test_feed_changeset_timeout + with_settings(:web_timeout => -1) do + get changeset_comments_feed_path(123) + end + assert_response :error + assert_equal "application/rss+xml; charset=utf-8", @response.header["Content-Type"] + assert_dom "rss>channel>title", :text => "OpenStreetMap changeset #123 discussion" + assert_dom "rss>channel>description", :text => /the list of changeset comments you requested took too long to retrieve/ + end end end diff --git a/test/controllers/nodes_controller_test.rb b/test/controllers/nodes_controller_test.rb index 5bb08ea71..a29432723 100644 --- a/test/controllers/nodes_controller_test.rb +++ b/test/controllers/nodes_controller_test.rb @@ -90,4 +90,15 @@ class NodesControllerTest < ActionDispatch::IntegrationTest assert_select ".secondary-actions a", :text => "View History", :count => 1 assert_select ".secondary-actions a", :text => "View Unredacted History", :count => 1 end + + def test_show_timeout + node = create(:node) + with_settings(:web_timeout => -1) do + get node_path(node) + end + assert_response :error + assert_template :layout => "map" + assert_dom "h2", "Timeout Error" + assert_dom "p", /#{Regexp.quote("the node with the id #{node.id}")}/ + end end diff --git a/test/controllers/old_nodes_controller_test.rb b/test/controllers/old_nodes_controller_test.rb index bb4dffdc6..abaf30d62 100644 --- a/test/controllers/old_nodes_controller_test.rb +++ b/test/controllers/old_nodes_controller_test.rb @@ -218,6 +218,17 @@ class OldNodesControllerTest < ActionDispatch::IntegrationTest assert_select "#sidebar_content", /node #0 version 0 could not be found/ end + def test_show_timeout + node = create(:node, :with_history) + with_settings(:web_timeout => -1) do + get old_node_path(node, 1) + end + assert_response :error + assert_template :layout => "map" + assert_dom "h2", "Timeout Error" + assert_dom "p", /#{Regexp.quote("the node with the id #{node.id}")}/ + end + private def create_redacted_node diff --git a/test/controllers/old_relations_controller_test.rb b/test/controllers/old_relations_controller_test.rb index a766f8b8d..f5de706cf 100644 --- a/test/controllers/old_relations_controller_test.rb +++ b/test/controllers/old_relations_controller_test.rb @@ -177,6 +177,17 @@ class OldRelationsControllerTest < ActionDispatch::IntegrationTest assert_select "#sidebar_content", /relation #0 version 0 could not be found/ end + def test_show_timeout + relation = create(:relation, :with_history) + with_settings(:web_timeout => -1) do + get old_relation_path(relation, 1) + end + assert_response :error + assert_template :layout => "map" + assert_dom "h2", "Timeout Error" + assert_dom "p", /#{Regexp.quote("the relation with the id #{relation.id}")}/ + end + private def create_redacted_relation diff --git a/test/controllers/old_ways_controller_test.rb b/test/controllers/old_ways_controller_test.rb index 6455343cf..fcc2281b8 100644 --- a/test/controllers/old_ways_controller_test.rb +++ b/test/controllers/old_ways_controller_test.rb @@ -182,6 +182,17 @@ class OldWaysControllerTest < ActionDispatch::IntegrationTest assert_select "#sidebar_content", /way #0 version 0 could not be found/ end + def test_show_timeout + way = create(:way, :with_history) + with_settings(:web_timeout => -1) do + get old_way_path(way, 1) + end + assert_response :error + assert_template :layout => "map" + assert_dom "h2", "Timeout Error" + assert_dom "p", /#{Regexp.quote("the way with the id #{way.id}")}/ + end + private def create_redacted_way diff --git a/test/controllers/relations_controller_test.rb b/test/controllers/relations_controller_test.rb index 926d95026..bdcbd2fd7 100644 --- a/test/controllers/relations_controller_test.rb +++ b/test/controllers/relations_controller_test.rb @@ -36,4 +36,15 @@ class RelationsControllerTest < ActionDispatch::IntegrationTest sidebar_browse_check :relation_path, member.id, "browse/feature" assert_select "a[href='#{relation_path relation}']", :count => 1 end + + def test_show_timeout + relation = create(:relation) + with_settings(:web_timeout => -1) do + get relation_path(relation) + end + assert_response :error + assert_template :layout => "map" + assert_dom "h2", "Timeout Error" + assert_dom "p", /#{Regexp.quote("the relation with the id #{relation.id}")}/ + end end diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb index 4f4edf10b..dda157f01 100644 --- a/test/controllers/users_controller_test.rb +++ b/test/controllers/users_controller_test.rb @@ -476,7 +476,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest moderator_user = create(:moderator_user) administrator_user = create(:administrator_user) _suspended_user = create(:user, :suspended) - _ip_user = create(:user, :creation_ip => "1.2.3.4") + _ip_user = create(:user, :creation_address => "1.2.3.4") # There are now 7 users - the five above, plus two extra "granters" for the # moderator_user and administrator_user diff --git a/test/controllers/ways_controller_test.rb b/test/controllers/ways_controller_test.rb index e198f7cf6..995004cb4 100644 --- a/test/controllers/ways_controller_test.rb +++ b/test/controllers/ways_controller_test.rb @@ -36,4 +36,15 @@ class WaysControllerTest < ActionDispatch::IntegrationTest sidebar_browse_check :way_path, member.id, "browse/feature" assert_select "a[href='#{relation_path relation}']", :count => 1 end + + def test_show_timeout + way = create(:way) + with_settings(:web_timeout => -1) do + get way_path(way) + end + assert_response :error + assert_template :layout => "map" + assert_dom "h2", "Timeout Error" + assert_dom "p", /#{Regexp.quote("the way with the id #{way.id}")}/ + end end diff --git a/test/system/users_test.rb b/test/system/users_test.rb new file mode 100644 index 000000000..5d5bf56d7 --- /dev/null +++ b/test/system/users_test.rb @@ -0,0 +1,28 @@ +require "application_system_test_case" + +class UsersTest < ApplicationSystemTestCase + def setup + admin = create(:administrator_user) + sign_in_as(admin) + end + + test "all users can be selected" do + create_list(:user, 100) + + visit users_path + + assert_css "tbody input[type=checkbox]:checked", :count => 0 + assert_css "tbody input[type=checkbox]:not(:checked)", :count => 50 + check "user_all" + assert_css "tbody input[type=checkbox]:checked", :count => 50 + assert_css "tbody input[type=checkbox]:not(:checked)", :count => 0 + + click_on "Older Users", :match => :first + + assert_css "tbody input[type=checkbox]:checked", :count => 0 + assert_css "tbody input[type=checkbox]:not(:checked)", :count => 50 + check "user_all" + assert_css "tbody input[type=checkbox]:checked", :count => 50 + assert_css "tbody input[type=checkbox]:not(:checked)", :count => 0 + end +end