Feature #16904

Add anonymous user to users list in query filters

Added by Felix Schäfer over 5 years ago. Updated 28 days ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Jean-Philippe Lang% Done:

0%

Category:Issues filter
Target version:4.1.0
Resolution:Fixed

Description

The author of an issue might be "Anonymous", either because issue creation is allowed for users that are not logged in, or because a user has been deleted. There's currently no way to filter by that user, the only way to achieve this is to filter for issues with an author that "is not all users".

16904-issuequery-filters-add-anonymous-user.patch Magnifier (1.91 KB) Yuichi HARADA, 2018-10-04 05:02

16904-issuequery-filters-add-anonymous-user-v2.patch Magnifier (1.34 KB) Go MAEDA, 2018-11-03 08:38

16904.patch Magnifier (1.06 KB) Marius BALTEANU, 2019-11-10 13:13

Associated revisions

Revision 19065
Added by Jean-Philippe Lang about 1 month ago

Add anonymous user to author list in issue/time query (#16904).

Patch by Yuichi HARADA and Go MAEDA.

Revision 19066
Added by Jean-Philippe Lang about 1 month ago

Merged r19065 to 4.1-stable (#16904).

Revision 19067
Added by Go MAEDA 28 days ago

Fix that QueriesControllerTest fails due to r19065 (#16904).

Patch by Marius BALTEANU.

Revision 19068
Added by Go MAEDA 28 days ago

Fix a Rubocop offense caused by r19065 (#16904).

Patch by Marius BALTEANU.

Revision 19069
Added by Go MAEDA 28 days ago

Merged r19067 from trunk to 4.1-stable (#16904).

Revision 19070
Added by Go MAEDA 28 days ago

Merged r19068 from trunk to 4.1-stable (#16904).

History

#1 Updated by Felix Schäfer over 5 years ago

This adds the option to search for issues with the author "Anonymous" everywhere.

diff --git a/app/models/issue_query.rb b/app/models/issue_query.rb
index bf90f56..1b9bf1e 100644
--- a/app/models/issue_query.rb
+++ b/app/models/issue_query.rb
@@ -171,6 +171,7 @@ class IssueQuery < Query
     author_values = []
     author_values << ["<< #{l(:label_me)} >>", "me"] if User.current.logged?
     author_values += users.collect{|s| [s.name, s.id.to_s] }
+    author_values << [l(:label_user_anonymous), User.anonymous.id.to_s]
     add_available_filter("author_id",
       :type => :list, :values => author_values
     ) unless author_values.empty?

#2 Updated by Deoren Moor about 5 years ago

+1

This would be useful to have. In addition (probably a separate issue), being able to filter on locked accounts would be nice to have as well.

#3 Updated by Go MAEDA about 1 year ago

  • Category set to Issues filter

#4 Updated by Yuichi HARADA about 1 year ago

I added an Anonymous user to the issues filter for "Author" and "Updated by" and "Last updated by".

#5 Updated by Go MAEDA about 1 year ago

  • Target version set to Candidate for next major release

#6 Updated by Go MAEDA about 1 year ago

Thank you for writing the patch.

But I think that not only IssuesQuery but also TimeEntryQuery should have an anonymous user in the author list because the User value of time entries can be an anonymous user.

#7 Updated by Go MAEDA about 1 month ago

  • Target version changed from Candidate for next major release to 4.1.0

Setting the target version to 4.1.0.

#8 Updated by Jean-Philippe Lang about 1 month ago

  • Subject changed from Add anonymous user to author list in issue query to Add anonymous user to users list in query filters
  • Status changed from New to Closed
  • Assignee set to Jean-Philippe Lang
  • Resolution set to Fixed

Committed, thanks.

#9 Updated by Marius BALTEANU about 1 month ago

  • File 16904.patchMagnifier added
  • Status changed from Closed to Reopened

A test is failling:


root@df2fd1389bf4:/work# ruby test/functional/queries_controller_test.rb -n test_user_filter_should_return_active_and_locked_users_grouped_by_status
Run options: -n test_user_filter_should_return_active_and_locked_users_grouped_by_status --seed 49890

# Running:

F

Failure:
QueriesControllerTest#test_user_filter_should_return_active_and_locked_users_grouped_by_status [test/functional/queries_controller_test.rb:778]:
Expected: 6
Actual: 7

and a new Rubocop offense:


root@df2fd1389bf4:/work# bundle exec rubocop test/functional/queries_controller_test.rb 
Inspecting 1 file
C

Offenses:

test/functional/queries_controller_test.rb:764:34: C: Style/RedundantInterpolation: Prefer to_s over string interpolation.
    assert_include ["Anonymous", "#{User.anonymous.id}"], json
                                 ^^^^^^^^^^^^^^^^^^^^^^

1 file inspected, 1 offense detected

The attach patch fixes both issues.

#10 Updated by Go MAEDA 28 days ago

  • Status changed from Reopened to Closed

Committed the fix 16904.patch. Thank you.

#11 Updated by Toshi MARUYAMA 28 days ago

  • Status changed from Closed to Reopened

#12 Updated by Marius BALTEANU 28 days ago

  • Status changed from Reopened to Closed

Toshi MARUYAMA wrote:

Tests fail on PostgreSQL.
http://www.redmine.org/builds/logs/build_trunk_postgresql_ruby-2.6_795.html

It is a known issue, please see #32436.

Also available in: Atom PDF