summaryrefslogtreecommitdiffstats
path: root/app/controllers/queries_controller.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2017-01-09 19:59:54 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2017-01-09 19:59:54 +0000
commitfd3c08aaa107e2c5a412a06aea6890b147e46aaf (patch)
tree6e55b3f482eddc77ff7cc7f593aa0754e9494a0b /app/controllers/queries_controller.rb
parent72f59192525bd6dc3af2cfa00d5b184892335c8d (diff)
downloadredmine-fd3c08aaa107e2c5a412a06aea6890b147e46aaf.tar.gz
redmine-fd3c08aaa107e2c5a412a06aea6890b147e46aaf.zip
Don't preload all query filters (#24787).
git-svn-id: http://svn.redmine.org/redmine/trunk@16170 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/queries_controller.rb')
-rw-r--r--app/controllers/queries_controller.rb21
1 files changed, 20 insertions, 1 deletions
diff --git a/app/controllers/queries_controller.rb b/app/controllers/queries_controller.rb
index fda9d9711..f7ef74882 100644
--- a/app/controllers/queries_controller.rb
+++ b/app/controllers/queries_controller.rb
@@ -17,7 +17,7 @@
class QueriesController < ApplicationController
menu_item :issues
- before_action :find_query, :except => [:new, :create, :index]
+ before_action :find_query, :only => [:edit, :update, :destroy]
before_action :find_optional_project, :only => [:new, :create]
accept_api_auth :index
@@ -85,6 +85,25 @@ class QueriesController < ApplicationController
redirect_to_items(:set_filter => 1)
end
+ # Returns the values for a query filter
+ def filter
+ q = query_class.new
+ if params[:project_id].present?
+ q.project = Project.find(params[:project_id])
+ end
+
+ unless User.current.allowed_to?(q.class.view_permission, q.project, :global => true)
+ raise Unauthorized
+ end
+
+ filter = q.available_filters[params[:name].to_s]
+ values = filter ? filter.values : []
+
+ render :json => values
+ rescue ActiveRecord::RecordNotFound
+ render_404
+ end
+
private
def find_query