mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-23 08:51:13 +00:00
Makes QueriesController able to handle other Query subclasses.
git-svn-id: http://svn.redmine.org/redmine/trunk@15635 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
1b9ca7219b
commit
9fb339c4e2
@ -31,9 +31,10 @@ class QueriesController < ApplicationController
|
|||||||
else
|
else
|
||||||
@limit = per_page_option
|
@limit = per_page_option
|
||||||
end
|
end
|
||||||
@query_count = IssueQuery.visible.count
|
scope = query_class.visible
|
||||||
|
@query_count = scope.count
|
||||||
@query_pages = Paginator.new @query_count, @limit, params['page']
|
@query_pages = Paginator.new @query_count, @limit, params['page']
|
||||||
@queries = IssueQuery.visible.
|
@queries = scope.
|
||||||
order("#{Query.table_name}.name").
|
order("#{Query.table_name}.name").
|
||||||
limit(@limit).
|
limit(@limit).
|
||||||
offset(@offset).
|
offset(@offset).
|
||||||
@ -45,14 +46,14 @@ class QueriesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@query = IssueQuery.new
|
@query = query_class.new
|
||||||
@query.user = User.current
|
@query.user = User.current
|
||||||
@query.project = @project
|
@query.project = @project
|
||||||
@query.build_from_params(params)
|
@query.build_from_params(params)
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@query = IssueQuery.new
|
@query = query_class.new
|
||||||
@query.user = User.current
|
@query.user = User.current
|
||||||
@query.project = @project
|
@query.project = @project
|
||||||
update_query_from_params
|
update_query_from_params
|
||||||
@ -85,8 +86,9 @@ class QueriesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def find_query
|
def find_query
|
||||||
@query = IssueQuery.find(params[:id])
|
@query = Query.find(params[:id])
|
||||||
@project = @query.project
|
@project = @query.project
|
||||||
render_403 unless @query.editable_by?(User.current)
|
render_403 unless @query.editable_by?(User.current)
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
@ -107,10 +109,10 @@ private
|
|||||||
@query.sort_criteria = params[:query] && params[:query][:sort_criteria]
|
@query.sort_criteria = params[:query] && params[:query][:sort_criteria]
|
||||||
@query.name = params[:query] && params[:query][:name]
|
@query.name = params[:query] && params[:query][:name]
|
||||||
if User.current.allowed_to?(:manage_public_queries, @query.project) || User.current.admin?
|
if User.current.allowed_to?(:manage_public_queries, @query.project) || User.current.admin?
|
||||||
@query.visibility = (params[:query] && params[:query][:visibility]) || IssueQuery::VISIBILITY_PRIVATE
|
@query.visibility = (params[:query] && params[:query][:visibility]) || Query::VISIBILITY_PRIVATE
|
||||||
@query.role_ids = params[:query] && params[:query][:role_ids]
|
@query.role_ids = params[:query] && params[:query][:role_ids]
|
||||||
else
|
else
|
||||||
@query.visibility = IssueQuery::VISIBILITY_PRIVATE
|
@query.visibility = Query::VISIBILITY_PRIVATE
|
||||||
end
|
end
|
||||||
@query
|
@query
|
||||||
end
|
end
|
||||||
@ -126,4 +128,10 @@ private
|
|||||||
redirect_to _project_issues_path(@project, options)
|
redirect_to _project_issues_path(@project, options)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns the Query subclass, IssueQuery by default
|
||||||
|
# for compatibility with previous behaviour
|
||||||
|
def query_class
|
||||||
|
Query.get_subclass(params[:type] || 'IssueQuery')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -144,6 +144,8 @@ class Query < ActiveRecord::Base
|
|||||||
class StatementInvalid < ::ActiveRecord::StatementInvalid
|
class StatementInvalid < ::ActiveRecord::StatementInvalid
|
||||||
end
|
end
|
||||||
|
|
||||||
|
include Redmine::SubclassFactory
|
||||||
|
|
||||||
VISIBILITY_PRIVATE = 0
|
VISIBILITY_PRIVATE = 0
|
||||||
VISIBILITY_ROLES = 1
|
VISIBILITY_ROLES = 1
|
||||||
VISIBILITY_PUBLIC = 2
|
VISIBILITY_PUBLIC = 2
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user