##// END OF EJS Templates
Adds Issue#visible_condition to build issue visibility statement....
Jean-Philippe Lang -
r5021:fba3d5d327c4
parent child
Show More
@@ -60,7 +60,7 class Issue < ActiveRecord::Base
60 validates_numericality_of :estimated_hours, :allow_nil => true
60 validates_numericality_of :estimated_hours, :allow_nil => true
61
61
62 named_scope :visible, lambda {|*args| { :include => :project,
62 named_scope :visible, lambda {|*args| { :include => :project,
63 :conditions => Project.allowed_to_condition(args.first || User.current, :view_issues) } }
63 :conditions => Issue.visible_condition(args.first || User.current) } }
64
64
65 named_scope :open, :conditions => ["#{IssueStatus.table_name}.is_closed = ?", false], :include => :status
65 named_scope :open, :conditions => ["#{IssueStatus.table_name}.is_closed = ?", false], :include => :status
66
66
@@ -86,6 +86,11 class Issue < ActiveRecord::Base
86 after_save :reschedule_following_issues, :update_nested_set_attributes, :update_parent_attributes, :create_journal
86 after_save :reschedule_following_issues, :update_nested_set_attributes, :update_parent_attributes, :create_journal
87 after_destroy :update_parent_attributes
87 after_destroy :update_parent_attributes
88
88
89 # Returns a SQL conditions string used to find all issues visible by the specified user
90 def self.visible_condition(user, options={})
91 Project.allowed_to_condition(user, :view_issues, options)
92 end
93
89 # Returns true if usr or current user is allowed to view the issue
94 # Returns true if usr or current user is allowed to view the issue
90 def visible?(usr=nil)
95 def visible?(usr=nil)
91 (usr || User.current).allowed_to?(:view_issues, self.project)
96 (usr || User.current).allowed_to?(:view_issues, self.project)
@@ -411,7 +411,7 class Query < ActiveRecord::Base
411 elsif project
411 elsif project
412 project_clauses << "#{Project.table_name}.id = %d" % project.id
412 project_clauses << "#{Project.table_name}.id = %d" % project.id
413 end
413 end
414 project_clauses << Project.allowed_to_condition(User.current, :view_issues)
414 project_clauses << Issue.visible_condition(User.current)
415 project_clauses.join(' AND ')
415 project_clauses.join(' AND ')
416 end
416 end
417
417
General Comments 0
You need to be logged in to leave comments. Login now