]> git.openstreetmap.org Git - rails.git/commitdiff
Merge remote-tracking branch 'upstream/pull/5788'
authorTom Hughes <tom@compton.nu>
Tue, 11 Mar 2025 18:08:37 +0000 (18:08 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 11 Mar 2025 18:08:37 +0000 (18:08 +0000)
app/controllers/users/lists_controller.rb
app/views/users/lists/show.html.erb
config/locales/en.yml
test/controllers/users/lists_controller_test.rb

index 7e3fa2a32801cb70854c8e4fc8b3f0dea9d70d66..59d1bc5419cbef71c148ddf09a9d072e356f7f7d 100644 (file)
@@ -13,12 +13,14 @@ module Users
     ##
     # display a list of users matching specified criteria
     def show
-      @params = params.permit(:status, :username, :ip, :before, :after)
+      @params = params.permit(:status, :username, :ip, :edits, :before, :after)
 
       users = User.all
       users = users.where(:status => @params[:status]) if @params[:status].present?
       users = users.where("LOWER(email) = LOWER(?) OR LOWER(NORMALIZE(display_name, NFKC)) = LOWER(NORMALIZE(?, NFKC))", @params[:username], @params[:username]) if @params[:username].present?
       users = users.where("creation_address <<= ?", @params[:ip]) if @params[:ip].present?
+      users = users.where(:changesets_count => 0) if @params[:edits] == "no"
+      users = users.where.not(:changesets_count => 0) if @params[:edits] == "yes"
 
       @users_count = users.limit(501).count
       @users_count = I18n.t("count.at_least_pattern", :count => 500) if @users_count > 500
index c3d15d18afe6656385195801474c89a299f5f4cb..3ba08a42acee96244ba83703acf56ba50d4ff788 100644 (file)
                          :autocomplete => "on",
                          :class => "form-control" %>
     </div>
+    <div class="mb-3 col-md-auto">
+      <%= select_tag :edits,
+                     options_for_select([[t(".has_edits"), "yes"], [t(".no_edits"), "no"]], params[:edits]),
+                     :include_blank => t(".edits"),
+                     :data => { :behavior => "category_dropdown" },
+                     :class => "form-select" %>
+    </div>
     <div class="mb-3 col-md-auto">
       <%= submit_tag t(".search"), :name => nil, :class => "btn btn-primary" %>
     </div>
index e8661906233974faf59781e767ddabcc3c0e96f3..04968211dba116bcb20809e40ae604bf8342d4a7 100644 (file)
@@ -2951,6 +2951,9 @@ en:
           deleted: Deleted
         name_or_email: Name or Email
         ip_address: IP Address
+        edits: Edits?
+        has_edits: Has Edits
+        no_edits: No Edits
         search: Search
       page:
         found_users:
index 724c43222b61a84869a1f7787919b8c45153c623..1bb0e86a2b56d06a9be3f7042ee08e98090b029e 100644 (file)
@@ -31,10 +31,12 @@ module Users
       name_user = create(:user, :display_name => "Test User")
       email_user = create(:user, :email => "test@example.com")
       ip_user = create(:user, :creation_address => "1.2.3.4")
+      edits_user = create(:user)
+      create(:changeset, :user => edits_user)
 
-      # There are now 9 users - the 7 above, plus two extra "granters" for the
+      # There are now 10 users - the 8 above, plus two extra "granters" for the
       # moderator_user and administrator_user
-      assert_equal 9, User.count
+      assert_equal 10, User.count
 
       # Shouldn't work when not logged in
       get users_list_path
@@ -59,7 +61,7 @@ module Users
       get users_list_path
       assert_response :success
       assert_template :show
-      assert_select "table#user_list tbody tr", :count => 9
+      assert_select "table#user_list tbody tr", :count => 10
 
       # Should be able to limit by status
       get users_list_path, :params => { :status => "suspended" }
@@ -108,6 +110,22 @@ module Users
       assert_select "table#user_list tbody tr", :count => 1 do
         assert_select "a[href='#{user_path(ip_user)}']", :count => 1
       end
+
+      # Should be able to limit to users with edits
+      get users_list_path, :params => { :edits => "yes" }
+      assert_response :success
+      assert_template :show
+      assert_select "table#user_list tbody tr", :count => 1 do
+        assert_select "a[href='#{user_path(edits_user)}']", :count => 1
+      end
+
+      # Should be able to limit to users with no edits
+      get users_list_path, :params => { :edits => "no" }
+      assert_response :success
+      assert_template :show
+      assert_select "table#user_list tbody tr", :count => 9 do
+        assert_select "a[href='#{user_path(edits_user)}']", :count => 0
+      end
     end
 
     def test_show_paginated