@@ -31,9 +31,10 class QueriesController < ApplicationController | |||
|
31 | 31 | else |
|
32 | 32 | @limit = per_page_option |
|
33 | 33 | end |
|
34 | @query_count = IssueQuery.visible.count | |
|
34 | scope = query_class.visible | |
|
35 | @query_count = scope.count | |
|
35 | 36 | @query_pages = Paginator.new @query_count, @limit, params['page'] |
|
36 |
@queries = |
|
|
37 | @queries = scope. | |
|
37 | 38 | order("#{Query.table_name}.name"). |
|
38 | 39 | limit(@limit). |
|
39 | 40 | offset(@offset). |
@@ -45,14 +46,14 class QueriesController < ApplicationController | |||
|
45 | 46 | end |
|
46 | 47 | |
|
47 | 48 | def new |
|
48 |
@query = |
|
|
49 | @query = query_class.new | |
|
49 | 50 | @query.user = User.current |
|
50 | 51 | @query.project = @project |
|
51 | 52 | @query.build_from_params(params) |
|
52 | 53 | end |
|
53 | 54 | |
|
54 | 55 | def create |
|
55 |
@query = |
|
|
56 | @query = query_class.new | |
|
56 | 57 | @query.user = User.current |
|
57 | 58 | @query.project = @project |
|
58 | 59 | update_query_from_params |
@@ -84,9 +85,10 class QueriesController < ApplicationController | |||
|
84 | 85 | redirect_to_issues(:set_filter => 1) |
|
85 | 86 | end |
|
86 | 87 | |
|
87 | private | |
|
88 | private | |
|
89 | ||
|
88 | 90 | def find_query |
|
89 |
@query = |
|
|
91 | @query = Query.find(params[:id]) | |
|
90 | 92 | @project = @query.project |
|
91 | 93 | render_403 unless @query.editable_by?(User.current) |
|
92 | 94 | rescue ActiveRecord::RecordNotFound |
@@ -107,10 +109,10 private | |||
|
107 | 109 | @query.sort_criteria = params[:query] && params[:query][:sort_criteria] |
|
108 | 110 | @query.name = params[:query] && params[:query][:name] |
|
109 | 111 | if User.current.allowed_to?(:manage_public_queries, @query.project) || User.current.admin? |
|
110 |
@query.visibility = (params[:query] && params[:query][:visibility]) || |
|
|
112 | @query.visibility = (params[:query] && params[:query][:visibility]) || Query::VISIBILITY_PRIVATE | |
|
111 | 113 | @query.role_ids = params[:query] && params[:query][:role_ids] |
|
112 | 114 | else |
|
113 |
@query.visibility = |
|
|
115 | @query.visibility = Query::VISIBILITY_PRIVATE | |
|
114 | 116 | end |
|
115 | 117 | @query |
|
116 | 118 | end |
@@ -126,4 +128,10 private | |||
|
126 | 128 | redirect_to _project_issues_path(@project, options) |
|
127 | 129 | end |
|
128 | 130 | end |
|
131 | ||
|
132 | # Returns the Query subclass, IssueQuery by default | |
|
133 | # for compatibility with previous behaviour | |
|
134 | def query_class | |
|
135 | Query.get_subclass(params[:type] || 'IssueQuery') | |
|
136 | end | |
|
129 | 137 | end |
General Comments 0
You need to be logged in to leave comments.
Login now