]> source.dussan.org Git - redmine.git/commitdiff
Make sure we cannot create a ProjectQuery on a given project (#29482).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 20 Nov 2019 15:53:04 +0000 (15:53 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 20 Nov 2019 15:53:04 +0000 (15:53 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@19093 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/project_query.rb

index 49c8f5e99040a075839219c938e00ea2fc017163..5957ecb418e69c1a745d807789d16212ebc4e898 100644 (file)
@@ -22,6 +22,11 @@ class ProjectQuery < Query
   self.queried_class = Project
   self.view_permission = :search_project
 
+  validate do |query|
+    # project must be blank for ProjectQuery
+    errors.add(:project_id, :exclusion) if query.project_id.present?
+  end
+
   self.available_columns = [
     QueryColumn.new(:name, :sortable => "#{Project.table_name}.name"),
     QueryColumn.new(:status, :sortable => "#{Project.table_name}.status"),