validates_inclusion_of :done_ratio, :in => 0..100
validates_numericality_of :estimated_hours, :allow_nil => true
+ named_scope :visible, lambda {|*args| { :include => :project,
+ :conditions => Project.allowed_to_condition(args.first || User.current, :view_issues) } }
+
def after_initialize
if new_record?
# set default values for new records only
<h3><%=l(:label_assigned_to_me_issues)%></h3>
-<% assigned_issues = Issue.find(:all,
- :conditions => ["assigned_to_id=? AND #{IssueStatus.table_name}.is_closed=? AND #{Project.table_name}.status=#{Project::STATUS_ACTIVE}", user.id, false],
+<% assigned_issues = Issue.visible.find(:all,
+ :conditions => ["assigned_to_id=? AND #{IssueStatus.table_name}.is_closed=?", user.id, false],
:limit => 10,
:include => [ :status, :project, :tracker, :priority ],
:order => "#{Enumeration.table_name}.position DESC, #{Issue.table_name}.updated_on DESC") %>
<h3><%=l(:label_reported_issues)%></h3>
-<% reported_issues = Issue.find(:all,
- :conditions => ["author_id=? AND #{Project.table_name}.status=#{Project::STATUS_ACTIVE}", user.id],
+<% reported_issues = Issue.visible.find(:all,
+ :conditions => { :author_id => user.id },
:limit => 10,
:include => [ :status, :project, :tracker ],
:order => "#{Issue.table_name}.updated_on DESC") %>
<h3><%=l(:label_watched_issues)%></h3>\r
-<% watched_issues = Issue.find(:all, \r
+<% watched_issues = Issue.visible.find(:all, \r
:include => [:status, :project, :tracker, :watchers],\r
:limit => 10, \r
- :conditions => ["#{Watcher.table_name}.user_id = ? AND #{Project.table_name}.status=#{Project::STATUS_ACTIVE}", user.id],\r
+ :conditions => ["#{Watcher.table_name}.user_id = ?", user.id],\r
:order => "#{Issue.table_name}.updated_on DESC") %>\r
<%= render :partial => 'issues/list_simple', :locals => { :issues => watched_issues } %>\r
<% if watched_issues.length > 0 %>\r