Actions
Maintenance #1960
closedxmera Omnia - Collection #1826: Maintenance tasks of several components
Maintenance #1739: Support Redmine 5.1.1
Check if project_query changes will have impact on plugins
Start date:
Due date:
% Done:
100%
Estimated time:
Compatible Redmine Version:
Pull Request Link:
Description
Affected plugins:
diff --git a/app/models/project_query.rb b/app/models/project_query.rb
index 740f36367..4224c0c37 100644
--- a/app/models/project_query.rb
+++ b/app/models/project_query.rb
@@ -18,6 +18,8 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class ProjectQuery < Query
+ attr_accessor :admin_projects
+
self.queried_class = Project
self.view_permission = :search_project
@@ -78,6 +80,12 @@ class ProjectQuery < Query
add_custom_fields_filters(project_custom_fields)
end
+ def build_from_params(params, defaults={})
+ query = super
+ query.admin_projects = params[:admin_projects]
+ query
+ end
+
def available_columns
return @available_columns if @available_columns
@@ -88,7 +96,28 @@ class ProjectQuery < Query
end
def available_display_types
- ['board', 'list']
+ if self.admin_projects
+ ['list']
+ else
+ ['board', 'list']
+ end
+ end
+
+ def display_type
+ if self.admin_projects
+ 'list'
+ else
+ super
+ end
+ end
+
+ def project_statuses_values
+ values = super
+ if self.admin_projects
+ values << [l(:project_status_archived), Project::STATUS_ARCHIVED.to_s]
+ values << [l(:project_status_scheduled_for_deletion), Project::STATUS_SCHEDULED_FOR_DELETION.to_s]
+ end
+ values
end
def default_columns_names
@@ -104,7 +133,11 @@ class ProjectQuery < Query
end
def base_scope
- Project.visible.where(statement)
+ if self.admin_projects
+ Project.where(statement)
+ else
+ Project.visible.where(statement)
+ end
end
def results_scope(options={})
Actions