Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[#36559] use User.current instead of passing current_user around

Tobias Dillmann2b3b369787c5
diff --git a/app/models/query.rb b/app/models/query.rb
index 0d7ac379e64..b188c2dd8cb 100644
--- a/app/models/query.rb
+++ b/app/models/query.rb
@@ -69,9 +69,9 @@ class Query < ApplicationRecord
scope(:global, -> { where(project_id: nil) })
- def self.new_default(attributes = nil, current_user = nil)
+ def self.new_default(attributes = nil)
new(attributes).tap do |query|
- query.current_user = current_user
+ query.current_user = User.current
query.add_default_filter
query.set_default_sort
query.show_hierarchies = true
diff --git a/lib/api/v3/queries/create_form_api.rb b/lib/api/v3/queries/create_form_api.rb
index 050632724ff..614e0489880 100644
--- a/lib/api/v3/queries/create_form_api.rb
+++ b/lib/api/v3/queries/create_form_api.rb
@@ -38,7 +38,7 @@ module API
helpers ::API::V3::Queries::QueryHelper
post do
- create_or_update_query_form Query.new_default({}, current_user), ::Queries::CreateContract, CreateFormRepresenter
+ create_or_update_query_form Query.new_default, ::Queries::CreateContract, CreateFormRepresenter
end
end
end
diff --git a/lib/api/v3/queries/update_form_api.rb b/lib/api/v3/queries/update_form_api.rb
index ac3c5d0c3a6..af04dd5af45 100644
--- a/lib/api/v3/queries/update_form_api.rb
+++ b/lib/api/v3/queries/update_form_api.rb
@@ -36,8 +36,6 @@ module API
helpers ::API::V3::Queries::QueryHelper
post do
- @query.current_user = current_user
-
# We try to ignore invalid aspects of the query as the user
# might not even be able to fix them (public query)
# and because they might only be invalid in his context