=,! including child projects operators now use validations

git-svn-id: https://dev.finn.de/svn/cockpit/branches/reporting_merge@1846 7926756e-e54e-46e6-9721-ed318f58905e
pull/6827/head
p.tessenow 14 years ago committed by jwollert
parent a96bf0cd15
commit 5a0684c4a3
  1. 8
      app/models/cost_query/operator.rb

@ -190,20 +190,16 @@ class CostQuery::Operator
end
end
new "=_child_projects", :label => :label_is_project_with_subprojects do
new "=_child_projects", :validate => :integers, :label => :label_is_project_with_subprojects do
def modify(query, field, value)
# ensure value is an integer
return query unless value.to_i.to_s == value.to_s
"=".to_operator.modify query, field, [value, *Project.find(value).children.map{ |p| p.id }]
rescue ActiveRecord::RecordNotFound
query
end
end
new "!_child_projects", :label => :label_is_not_project_with_subprojects do
new "!_child_projects", :validate => :integers, :label => :label_is_not_project_with_subprojects do
def modify(query, field, value)
# ensure value is an integer
return query unless value.to_i.to_s == value.to_s
"!".to_operator.modify query, field, [value, *Project.find(value).children.map{ |p| p.id }]
rescue ActiveRecord::RecordNotFound
query

Loading…
Cancel
Save