From: Anton Khorev Date: Thu, 12 Sep 2024 06:43:56 +0000 (+0300) Subject: Merge branch 'pull/5182' X-Git-Tag: live~176 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/e2a6701696761f8f290796a0b4c30df9a7425ea4?hp=336ad6db0363ce61a62ca902f89694017fd610d3 Merge branch 'pull/5182' --- diff --git a/app/abilities/ability.rb b/app/abilities/ability.rb index d6584f364..9a8f193a1 100644 --- a/app/abilities/ability.rb +++ b/app/abilities/ability.rb @@ -7,7 +7,7 @@ class Ability can :query, :browse can :show, [Node, Way, Relation] can [:index, :show], [OldNode, OldWay, OldRelation] - can [:show, :new], Note + can [:show, :create], Note can :search, :direction can [:index, :permalink, :edit, :help, :fixthemap, :offline, :export, :about, :communities, :preview, :copyright, :key, :id], :site can [:finish, :embed], :export @@ -20,11 +20,11 @@ class Ability can [:index, :rss, :show], DiaryEntry can :index, DiaryComment can [:index], Note - can [:new, :create, :update], :password + can [:create, :update], :password can [:index, :show], Redaction - can [:new, :create, :destroy], :session + can [:create, :destroy], :session can [:index, :show, :data, :georss], Trace - can [:terms, :new, :create, :save, :suspended, :show, :auth_success, :auth_failure], User + can [:terms, :create, :save, :suspended, :show, :auth_success, :auth_failure], User can [:index, :show, :blocks_on, :blocks_by], UserBlock end @@ -34,21 +34,21 @@ class Ability if Settings.status != "database_offline" can [:subscribe, :unsubscribe], Changeset - can [:index, :new, :create, :show, :update, :destroy], :oauth2_application + can [:index, :create, :show, :update, :destroy], :oauth2_application can [:index, :destroy], :oauth2_authorized_application - can [:new, :show, :create, :destroy], :oauth2_authorization + can [:show, :create, :destroy], :oauth2_authorization can [:update, :destroy], :account can [:show], :dashboard - can [:new, :create, :subscribe, :unsubscribe], DiaryEntry + can [:create, :subscribe, :unsubscribe], DiaryEntry can :update, DiaryEntry, :user => user can [:create], DiaryComment can [:make_friend, :remove_friend], Friendship - can [:new, :create, :reply, :show, :inbox, :outbox, :muted, :mark, :unmute, :destroy], Message + can [:create, :reply, :show, :inbox, :outbox, :muted, :mark, :unmute, :destroy], Message can [:close, :reopen], Note can [:show, :update], :preference can :update, :profile - can [:new, :create], Report - can [:mine, :new, :create, :update, :destroy], Trace + can :create, Report + can [:mine, :create, :update, :destroy], Trace can [:account, :go_public], User can [:index, :create, :destroy], UserMute @@ -56,8 +56,8 @@ class Ability can [:hide, :unhide], [DiaryEntry, DiaryComment] can [:index, :show, :resolve, :ignore, :reopen], Issue can :create, IssueComment - can [:new, :create, :update, :destroy], Redaction - can [:new, :create, :revoke_all], UserBlock + can [:create, :update, :destroy], Redaction + can [:create, :revoke_all], UserBlock can :update, UserBlock, :creator => user can :update, UserBlock, :revoker => user can :update, UserBlock, :active? => true diff --git a/app/controllers/user_blocks_controller.rb b/app/controllers/user_blocks_controller.rb index 7d61366be..c42c2659d 100644 --- a/app/controllers/user_blocks_controller.rb +++ b/app/controllers/user_blocks_controller.rb @@ -25,7 +25,7 @@ class UserBlocksController < ApplicationController @show_user_name = true @show_creator_name = true - render :partial => "blocks" if turbo_frame_request_id == "pagination" + render :partial => "page" if turbo_frame_request_id == "pagination" end def show @@ -127,7 +127,7 @@ class UserBlocksController < ApplicationController @show_user_name = false @show_creator_name = true - render :partial => "blocks" if turbo_frame_request_id == "pagination" + render :partial => "page" if turbo_frame_request_id == "pagination" end ## @@ -142,7 +142,7 @@ class UserBlocksController < ApplicationController @show_user_name = true @show_creator_name = false - render :partial => "blocks" if turbo_frame_request_id == "pagination" + render :partial => "page" if turbo_frame_request_id == "pagination" end private diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 3ba914210..fc893c9c3 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -38,7 +38,9 @@ class UsersController < ApplicationController users = users.where(:status => @params[:status]) if @params[:status] users = users.where(:creation_ip => @params[:ip]) if @params[:ip] - @users_count = users.count + @users_count = users.limit(501).count + @users_count = I18n.t("count.at_least_pattern", :count => 500) if @users_count > 500 + @users, @newer_users_id, @older_users_id = get_page_items(users, :limit => 50) render :partial => "page" if turbo_frame_request_id == "pagination" diff --git a/app/views/changesets/index.html.erb b/app/views/changesets/index.html.erb index 97e6351a0..fc5f7cbbc 100644 --- a/app/views/changesets/index.html.erb +++ b/app/views/changesets/index.html.erb @@ -13,9 +13,9 @@ <% end -%> <% elsif params[:bbox] %> -

<%= t(params[:max_id] ? ".no_more_area" : ".empty_area") %>

+

<%= params[:max_id] ? t(".no_more_area") : t(".empty_area") %>

<% elsif params[:display_name] %> -

<%= t(params[:max_id] ? ".no_more_user" : ".empty_user") %>

+

<%= params[:max_id] ? t(".no_more_user") : t(".empty_user") %>

<% else %> -

<%= t(params[:max_id] ? ".no_more" : ".empty") %>

+

<%= params[:max_id] ? t(".no_more") : t(".empty") %>

<% end %> diff --git a/app/views/redactions/index.html.erb b/app/views/redactions/index.html.erb index b6b6ef46e..26dad64cf 100644 --- a/app/views/redactions/index.html.erb +++ b/app/views/redactions/index.html.erb @@ -10,3 +10,9 @@ <% else %>

<%= t ".empty" %>

<% end %> + +<% if can?(:create, Redaction) %> +
+ <%= link_to t(".new"), new_redaction_path, :class => "btn btn-outline-primary" %> +
+<% end %> diff --git a/app/views/redactions/show.html.erb b/app/views/redactions/show.html.erb index 5b9749a51..fe073d123 100644 --- a/app/views/redactions/show.html.erb +++ b/app/views/redactions/show.html.erb @@ -18,7 +18,7 @@ <%= link_to t(".edit"), edit_redaction_path(@redaction), :class => "btn btn-outline-primary" %> <% end %> <% if can?(:destroy, Redaction) %> - <%= link_to t(".destroy"), @redaction, :method => "delete", :class => "btn btn-outline-danger", :remote => true, :data => { :confirm => t(".confirm") } %> + <%= link_to t(".destroy"), @redaction, :class => "btn btn-outline-danger", :data => { :turbo => true, :turbo_method => "DELETE", :turbo_confirm => t(".confirm") } %> <% end %> <% end %> diff --git a/app/views/user_blocks/_blocks.html.erb b/app/views/user_blocks/_page.html.erb similarity index 100% rename from app/views/user_blocks/_blocks.html.erb rename to app/views/user_blocks/_page.html.erb diff --git a/app/views/user_blocks/blocks_by.html.erb b/app/views/user_blocks/blocks_by.html.erb index 38254a5a3..73748e557 100644 --- a/app/views/user_blocks/blocks_by.html.erb +++ b/app/views/user_blocks/blocks_by.html.erb @@ -7,7 +7,7 @@ <% end %> <% unless @user_blocks.empty? %> -<%= render :partial => "blocks" %> +<%= render :partial => "page" %> <% else %>

<%= t ".empty", :name => @user.display_name %>

<% end %> diff --git a/app/views/user_blocks/blocks_on.html.erb b/app/views/user_blocks/blocks_on.html.erb index 38254a5a3..73748e557 100644 --- a/app/views/user_blocks/blocks_on.html.erb +++ b/app/views/user_blocks/blocks_on.html.erb @@ -7,7 +7,7 @@ <% end %> <% unless @user_blocks.empty? %> -<%= render :partial => "blocks" %> +<%= render :partial => "page" %> <% else %>

<%= t ".empty", :name => @user.display_name %>

<% end %> diff --git a/app/views/user_blocks/index.html.erb b/app/views/user_blocks/index.html.erb index 854d62037..5b040e2b5 100644 --- a/app/views/user_blocks/index.html.erb +++ b/app/views/user_blocks/index.html.erb @@ -7,7 +7,7 @@ <% end %> <% unless @user_blocks.empty? %> -<%= render :partial => "blocks" %> +<%= render :partial => "page" %> <% else %>

<%= t ".empty" %>

<% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 9a383569e..16015d92c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2833,15 +2833,9 @@ en: doesnt_have_role: "The user does not have role %{role}." not_revoke_admin_current_user: "Cannot revoke administrator role from current user." grant: - title: Confirm role granting - heading: Confirm role granting are_you_sure: "Are you sure you want to grant the role `%{role}' to the user `%{name}'?" - confirm: "Confirm" revoke: - title: Confirm role revoking - heading: Confirm role revoking are_you_sure: "Are you sure you want to revoke the role `%{role}' from the user `%{name}'?" - confirm: "Confirm" user_blocks: model: non_moderator_update: "Must be a moderator to create or update a block." @@ -2927,7 +2921,7 @@ en: not_revoked: "(not revoked)" show: "Show" edit: "Edit" - blocks: + page: display_name: "Blocked User" creator_name: "Creator" reason: "Reason for block" @@ -3204,6 +3198,7 @@ en: empty: "No redactions to show." heading: "List of Redactions" title: "List of Redactions" + new: "New Redaction" new: heading: "Enter Information for New Redaction" title: "Creating New Redaction" diff --git a/test/controllers/redactions_controller_test.rb b/test/controllers/redactions_controller_test.rb index 5ca72fe47..b3bc4cf16 100644 --- a/test/controllers/redactions_controller_test.rb +++ b/test/controllers/redactions_controller_test.rb @@ -102,7 +102,7 @@ class RedactionsControllerTest < ActionDispatch::IntegrationTest # create an empty redaction redaction = create(:redaction) - delete redaction_path(:id => redaction) + delete redaction_path(redaction) assert_redirected_to(redactions_path) end @@ -113,7 +113,7 @@ class RedactionsControllerTest < ActionDispatch::IntegrationTest redaction = create(:redaction) create(:old_node, :redaction => redaction) - delete redaction_path(:id => redaction) + delete redaction_path(redaction) assert_redirected_to(redaction_path(redaction)) assert_match(/^Redaction is not empty/, flash[:error]) end @@ -121,28 +121,28 @@ class RedactionsControllerTest < ActionDispatch::IntegrationTest def test_delete_non_moderator session_for(create(:user)) - delete redaction_path(:id => create(:redaction)) + delete redaction_path(create(:redaction)) assert_redirected_to :controller => "errors", :action => "forbidden" end def test_edit redaction = create(:redaction) - get edit_redaction_path(:id => redaction) + get edit_redaction_path(redaction) assert_redirected_to login_path(:referer => edit_redaction_path(redaction)) end def test_edit_moderator session_for(create(:moderator_user)) - get edit_redaction_path(:id => create(:redaction)) + get edit_redaction_path(create(:redaction)) assert_response :success end def test_edit_non_moderator session_for(create(:user)) - get edit_redaction_path(:id => create(:redaction)) + get edit_redaction_path(create(:redaction)) assert_redirected_to :controller => "errors", :action => "forbidden" end @@ -151,7 +151,7 @@ class RedactionsControllerTest < ActionDispatch::IntegrationTest redaction = create(:redaction) - put redaction_path(:id => redaction, :redaction => { :title => "Foo", :description => "Description here." }) + put redaction_path(redaction, :redaction => { :title => "Foo", :description => "Description here." }) assert_redirected_to(redaction_path(redaction)) end @@ -160,7 +160,7 @@ class RedactionsControllerTest < ActionDispatch::IntegrationTest redaction = create(:redaction) - put redaction_path(:id => redaction, :redaction => { :title => "Foo", :description => "" }) + put redaction_path(redaction, :redaction => { :title => "Foo", :description => "" }) assert_response :success assert_template :edit end @@ -170,7 +170,7 @@ class RedactionsControllerTest < ActionDispatch::IntegrationTest redaction = create(:redaction) - put redaction_path(:id => redaction, :redaction => { :title => "Foo", :description => "Description here." }) + put redaction_path(redaction, :redaction => { :title => "Foo", :description => "Description here." }) assert_redirected_to :controller => "errors", :action => "forbidden" end end diff --git a/test/system/redaction_destroy_test.rb b/test/system/redaction_destroy_test.rb new file mode 100644 index 000000000..db0b016a4 --- /dev/null +++ b/test/system/redaction_destroy_test.rb @@ -0,0 +1,33 @@ +require "application_system_test_case" + +class RedactionDestroyTest < ApplicationSystemTestCase + test "fails to delete nonempty redaction" do + redaction = create(:redaction, :title => "Some-unwanted-data-redaction") + create(:old_node, :redaction => redaction) + + sign_in_as create(:moderator_user) + visit redaction_path(redaction) + assert_text "Some-unwanted-data-redaction" + + accept_alert do + click_on "Remove this redaction" + end + assert_text "Redaction is not empty" + assert_text "Some-unwanted-data-redaction" + end + + test "deletes empty redaction" do + redaction = create(:redaction, :title => "No-unwanted-data-redaction") + + sign_in_as create(:moderator_user) + visit redaction_path(redaction) + assert_text "No-unwanted-data-redaction" + + accept_alert do + click_on "Remove this redaction" + end + assert_text "Redaction destroyed" + assert_text "List of Redactions" + assert_no_text "No-unwanted-data-redaction" + end +end