showing only these reports, that are global or belong to the current project

pull/6827/head
Gregor Schmidt 13 years ago
parent 0887b0dbd3
commit 9d7a5e7c7d
  1. 24
      app/controllers/cost_reports_controller.rb

@ -188,11 +188,31 @@ class CostReportsController < ApplicationController
end
def public_queries
CostQuery.find(:all, :conditions => "is_public = 1", :order => "name ASC")
if @project
CostQuery.find(:all,
:conditions => ["is_public = ? AND (project_id IS NULL OR project_id = ?)",
true, @project],
:order => "name ASC")
else
CostQuery.find(:all,
:conditions => ["is_public = ? AND project_id IS NULL",
true],
:order => "name ASC")
end
end
def private_queries
CostQuery.find(:all, :conditions => "user_id = #{current_user.id} AND is_public = 0", :order => "name ASC")
if @project
CostQuery.find(:all,
:conditions => ["user_id = ? AND is_public = ? AND (project_id IS NULL OR project_id = ?)",
current_user, false, @project],
:order => "name ASC")
else
CostQuery.find(:all,
:conditions => ["user_id = ? AND is_public = ? AND project_id IS NULL",
current_user, false],
:order => "name ASC")
end
end
private

Loading…
Cancel
Save