summaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/projects_controller.rb18
-rw-r--r--app/controllers/queries_controller.rb6
2 files changed, 19 insertions, 5 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 98571b8f9..e7a79e495 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -33,6 +33,7 @@ class ProjectsController < ApplicationController
helper :custom_fields
helper :issues
helper :queries
+ include QueriesHelper
helper :repositories
helper :members
helper :trackers
@@ -44,13 +45,11 @@ class ProjectsController < ApplicationController
return
end
- scope = Project.visible.sorted
+ retrieve_project_query
+ scope = project_scope
respond_to do |format|
format.html {
- unless params[:closed]
- scope = scope.active
- end
@projects = scope.to_a
}
format.api {
@@ -257,4 +256,15 @@ class ProjectsController < ApplicationController
# hide project in layout
@project = nil
end
+
+ private
+
+ # Returns the ProjectEntry scope for index
+ def project_scope(options={})
+ @query.results_scope(options)
+ end
+
+ def retrieve_project_query
+ retrieve_query(ProjectQuery, false)
+ end
end
diff --git a/app/controllers/queries_controller.rb b/app/controllers/queries_controller.rb
index 10051ab02..348806198 100644
--- a/app/controllers/queries_controller.rb
+++ b/app/controllers/queries_controller.rb
@@ -126,7 +126,7 @@ class QueriesController < ApplicationController
@query.column_names = nil if params[:default_columns]
@query.sort_criteria = (params[:query] && params[:query][:sort_criteria]) || @query.sort_criteria
@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.type == 'ProjectQuery' && User.current.allowed_to?(:manage_public_queries, @query.project, :global => true))
@query.visibility = (params[:query] && params[:query][:visibility]) || Query::VISIBILITY_PRIVATE
@query.role_ids = params[:query] && params[:query][:role_ids]
else
@@ -156,6 +156,10 @@ class QueriesController < ApplicationController
redirect_to _time_entries_path(@project, nil, options)
end
+ def redirect_to_project_query(options)
+ redirect_to projects_path(options)
+ end
+
# Returns the Query subclass, IssueQuery by default
# for compatibility with previous behaviour
def query_class