else
@limit = per_page_option
end
- @query_count = IssueQuery.visible.count
+ scope = query_class.visible
+ @query_count = scope.count
@query_pages = Paginator.new @query_count, @limit, params['page']
- @queries = IssueQuery.visible.
+ @queries = scope.
order("#{Query.table_name}.name").
limit(@limit).
offset(@offset).
end
def new
- @query = IssueQuery.new
+ @query = query_class.new
@query.user = User.current
@query.project = @project
@query.build_from_params(params)
end
def create
- @query = IssueQuery.new
+ @query = query_class.new
@query.user = User.current
@query.project = @project
update_query_from_params
redirect_to_issues(:set_filter => 1)
end
-private
+ private
+
def find_query
- @query = IssueQuery.find(params[:id])
+ @query = Query.find(params[:id])
@project = @query.project
render_403 unless @query.editable_by?(User.current)
rescue ActiveRecord::RecordNotFound
@query.sort_criteria = params[:query] && params[:query][:sort_criteria]
@query.name = params[:query] && params[:query][:name]
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]
else
- @query.visibility = IssueQuery::VISIBILITY_PRIVATE
+ @query.visibility = Query::VISIBILITY_PRIVATE
end
@query
end
redirect_to _project_issues_path(@project, options)
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